-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
288 lines (217 loc) · 8.8 KB
/
vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
" Forget being compatible with good ol' vi
set nocompatible
" Manage plugins as bundles for easy install/remove/update
" pass a string argument to use another folder other than bundle
execute pathogen#infect()
" Colorscheme (terminal must support 256 colors)
" Drop gnome-terminal, urxvt is where's it's at
set t_Co=256
"colorscheme xoria256
"colorscheme mustang
colorscheme molokai
" this one will hurt your eyes... and it's a mac theme trolol
"colorscheme vividchalk
"change to a specialized colorscheme when entering vimdiff
if &diff
colorscheme xoria256
endif
" Get that filetype stuff happening
filetype plugin indent on
" Turn on that syntax highlighting
syntax on
" Syntax coloring lines that are too long just slows down the world
set synmaxcol=2048
" By setting ‘hidden’ you’re telling Vim that it’s OK to have an
" unwritten buffer that’s no longer visible.
" If you’ve got 12 buffers and 2 windows then there are 10 buffers that
" aren’t visible and if you set ‘nohidden’ then that means that
" those 10 buffers must be written to disk. If they aren’t written to disk then
" they would have to be visible.
set hidden
" Don't update the display while executing macros
"set lazyredraw
" At least let yourself know what mode you're in
set showmode
" Enable enhanced command-line completion. Presumes you have compiled
" with +wildmenu. See :help 'wildmenu'
set wildmenu
set wildmode=longest,list,full
" Set the search scan to wrap around the file
set wrapscan
" Make command line two lines high
set ch=2
" set visual bell -- I hate that damned beeping
set vb
" Allow backspacing over indent, eol, and the start of an insert
set backspace=2
" Set the status line the way I like it
set stl=%f\ %y%{'['.(&fenc==''?&enc:&fenc).']'}%m%r\ %l/%L\ %c\ #%n
" set stl=%f\ %y%{'['.(&fenc==''?&enc:&fenc).']'}%m%r\ %l/%L\ %c\ #%n\ [%b][0x%B] " with ASCII codes
" tell Vim to always put a status line in, even if there is only one
" window
set laststatus=2
" Hide the mouse pointer while typing
set mousehide
" Keep some stuff in the history
set history=100
" No backups, you should know what you're doing Zack
set nobackup
set nowritebackup
" These commands open folds
set foldopen=block,insert,jump,mark,percent,quickfix,search,tag,undo
" Set foldlevelstart to 1 to avoid
" completely folding newly opened files
set foldlevelstart=1
" Too many nested folds are annoying,
" put an end to it
set foldnestmax=2
" Set how the folds look
set foldtext=strpart(getline(v:foldstart),0,50).'\ ...\ '.substitute(getline(v:foldend),'^[\ #]*','','g').'\ '
" When the page starts to scroll, keep the cursor 8 lines from
" the top and 8 lines from the bottom
set scrolloff=8
" Allow the cursor to go in to 'invalid' places
"set virtualedit=all
" Number of spaces that a <Tab> in the file counts for
set tabstop=2
" Number of spaces to use for each step of (auto)indent
set shiftwidth=2
" Use the appropriate number of spaces to insert a <Tab>.
" Spaces are used in indents with the '>' and '<' commands
" and when 'autoindent' is on. To insert a real tab when
" 'expandtab' is on, use CTRL-V <Tab>
set expandtab
" When on, a <Tab> in front of a line inserts blanks
" according to 'shiftwidth'. 'tabstop' is used in other
" places. A <BS> will delete a 'shiftwidth' worth of space
" at the start of the line
"set smarttab
set softtabstop=2
" Display extra whitespace
" tabs as »· (might be displayed as spaces if expand tab is on)
" spaces as ·
" If you want to change color, trail and eol chars are SpecialKey
"set list listchars=tab:»·,trail:·
" Show (partial) command in status line
set showcmd
" Show line numbers
"set number
" Show relative line numbers
" This changes Vim’s line number column to display
" how far away each line is from the current one,
" instead of showing the absolute line number
"set relativenumber
" When a bracket is inserted, briefly jump to the matching
" one. The jump is only done if the match can be seen on the
" screen. The time to show the match can be set with 'matchtime'
set showmatch
" When there is a previous search pattern, highlight all its matches
set hlsearch
" Incrementally match the search
set incsearch
" Ignore case in search patterns
set ignorecase
" Override the 'ignorecase' option if the search pattern
" contains upper case characters
set smartcase
" Copy indent from current line when starting a new line
" (typing <CR> in Insert mode or when using the "o" or "O" command)
set autoindent
" Maximum width of text that is being inserted. A longer
" line will be broken after white space to get this width
set textwidth=80
" This is a sequence of letters which describes how
" automatic formatting is to be done.
"
" letter meaning when present in 'formatoptions'
" ------ ---------------------------------------
" c Auto-wrap comments using textwidth, inserting
" the current comment leader automatically.
" q Allow formatting of comments with "gq".
" r Automatically insert the current comment leader
" after hitting <Enter> in Insert mode.
" t Auto-wrap text using textwidth (does not apply
" to comments)
set formatoptions=c,q
" Show the line and column number of the cursor position, separated by a comma
" set ruler
" Open new horizontal split windows on the right instead of left
" and new vertical split windows bellow instead of above
set splitright
set splitbelow
"-----------------------------------------------------------------------------"
" Useful tidbits/workarounds
"-----------------------------------------------------------------------------"
" Fold CSS files by bracket and also close them upon opening file
" no matter what foldlevel is set to globally
autocmd BufNewFile,BufRead *.css set fdm=marker fmr={,} fdl=0
" Also map { to add closing bracket two lines bellow and jump to
" middle line
"autocmd BufNewFile,BufRead *.css inoremap { {<CR>}<Esc>ko
" Don't screw up folds when inserting text that might affect them, until
" leaving insert mode. Foldmethod is local to the window. Protect against
" screwing up folding when switching between windows.
autocmd InsertEnter * if !exists('w:last_fdm') | let w:last_fdm=&foldmethod | setlocal foldmethod=manual | endif
autocmd InsertLeave,WinLeave * if exists('w:last_fdm') | let &l:foldmethod=w:last_fdm | unlet w:last_fdm | endif
autocmd FileType ruby setlocal foldnestmax=5
"-----------------------------------------------------------------------------"
" REMEMBER, :verbose *map (imap, nnoremap, etc) IS YOUR BEST FRIEND!!!
"-----------------------------------------------------------------------------"
" Turn off search highlight until the next search
" useful once you've found what you were looking for
nmap <silent> ,l :noh<CR>
" Strip all trailing whitespace in the current file
nmap <silent> ,s :%s/\s\+$//<CR>:let @/=''<CR>:echo 'All trailing whitespace stripped'<CR>
" Correct indentation on the whole file
" (be careful with commented methods and stuff)
nmap <silent> ,f ggVG=<Esc>
" Close all folds recursively then open firstlevel
nmap <silent> zM zMzo
" Sort all CSS properties alphabetically
" while keeping webkit and moz properties
" together with their CSS3 counterpart
" (must be nnoremap otherwise would expand j,V, etc...)
nnoremap <silent> ,c ?{<CR>jV/\v^\s*\}?$<CR>k:sort/\s*\(-\a*-\\|\)/<CR>:noh<CR>
"nnoremap <silent> ,c ?{<CR>jV/\v^\s*\}?$<CR>k:sort<CR>:noh<CR> completely alphabetical
" Smart way to move between windows
map <C-n> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Paste mode
nnoremap <F2> :set invpaste paste?<CR>
set pastetoggle=<F2>
" Toggle NERDtree
nmap <silent> ,n :NERDTreeToggle<CR>
" Toggle spell check
nmap <silent> ,c :set spell!<CR>
"-----------------------------------------------------------------------------"
" PLUGINS
"-----------------------------------------------------------------------------"
" NERDtree configuration
" Specify which files the NERD tree should ignore
let NERDTreeIgnore=['\~$', '\.swp$', '\.svn$', '\.git$']
" Open bookmarks on startup
"let NERDTreeShowBookmarks=1
" Closes the tree window after opening a file
let NERDTreeQuitOnOpen=1
" LaTeX-suite configuration
" IMPORTANT -- grep will sometimes skip displaying the file name if you search in a
" single file. This will confuse LaTeX-suite. Set grep program to always
" generate a file-name
set grepprg=grep\ -nH\ $*
" OPTIONAL -- Starting with vim 7, the filetype of empty .tex files defaults to
" 'plaintex' instead of 'tex', which results in vim-latex not being loaded.
" The following changes the default filetype back to 'tex'
let g:tex_flavor='latex'
" Set the default output of latex as pdf
let g:Tex_DefaultTargetFormat='pdf'
" Set default pdf viewer
let g:Tex_ViewRule_pdf='xdg-open'
" Don't Want Spell Checking In Comments?
let g:tex_comment_nospell= 1
" Ruby configuration
" Enable folds...
let ruby_fold=1
" ...but not on comments
let ruby_no_comment_fold=1