-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
executable file
·382 lines (316 loc) · 8.62 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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
" load pathogen
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle
call vundle#rc()
" let vundle manage vundle
Bundle 'gmarik/vundle'
Bundle 'Valloric/YouCompleteMe'
Bundle 'kien/ctrlp.vim'
Bundle 'gregsexton/gitv'
Bundle 'scrooloose/nerdtree'
Bundle 'tpope/vim-surround'
Bundle 'godlygeek/tabular'
Bundle 'altercation/vim-colors-solarized'
Bundle 'jeetsukumaran/vim-filesearch'
Bundle 'tpope/vim-fugitive'
Bundle 'xolox/vim-notes'
" disabled due to errors/warnings
"Bundle 'vim-scripts/pep8'
"Bundle 'msanders/snipmate.vim'
" remove old autocommands
autocmd!
" detect windows version of gVim
function! RunningWindows()
return has('win16') || has('win32') || has('win64')
endfunction
" detect mac version of gVim
function! RunningMac()
return has('mac')
endfunction
" map a leader character for keybindings
let mapleader = ","
" no more bells and whistles
set visualbell
set t_vb=
" in windows the above doesn't seem to register when running gVim, so use the
" following to force the bloody screen flash to go away
autocmd GuiEnter * set t_vb=
" reduce "hit-enter" prompts
set shortmess=a
" enable better buffer handling
set hidden
" longer history
set history=200
" general ui settings
set ruler
set showcmd
" shorten some command line tokens
set shortmess=atI
" better autocompletion
set wildmenu
set wildmode=list:longest
" smart case in searches: "/" search will be case insensitive unless terms
" contain a capital letter
set ignorecase
set smartcase
" filetype detection
filetype on
filetype plugin on
filetype indent on
" syntax settings
syntax enable
" search settings
set incsearch
set hlsearch
" tab settings
set autoindent
set smarttab
set tabstop=4
set shiftwidth=4
set softtabstop=4
set listchars=tab:>-
set noexpandtab
" backspace settings
set backspace=indent,eol,start
" set sm
set tags=tags;/
" mac file format support
set fileformats=unix,dos,mac
" escape insert mode with jj
imap jj <Esc>
" keybindings
map <F8> :set list!<CR>
" helpful mappings for opening files in the same folder
map <leader>ew :e <C-R>=expand("%:p:h") . "/" <CR>
map <leader>es :sp <C-R>=expand("%:p:h") . "/" <CR>
map <leader>ev :vsp <C-R>=expand("%:p:h") . "/" <CR>
map <leader>et :tabe <C-R>=expand("%:p:h") . "/" <CR>
" for Vim 7 only
if version >= 700
" keybindings for tabbed windows
map <leader>t :tabnew
map <leader>T :tabnew<CR>
map <leader>D :tabclose<CR>
""map <leader>D :tabonly<CR>
" shell integration
map <leader>hh :ConqueTerm
map <leader>hb :ConqueTerm bash<CR>
" NERDTree support
try
map <leader>n :execute 'NERDTreeToggle ' . escape(getcwd(), '\ ')<CR>
map <leader>N :NERDTree
map <leader>m :Bookmark
map <leader>' :BookmarkToRoot
catch
endtry
endif
" cscope integration
map <leader>ga :cs add
map <leader>gs :cs find s <cword><CR>
map <leader>gg :cs find g <cword><CR>
map <leader>gd :cs find d <cword><CR>
map <leader>gc :cs find c <cword><CR>
map <leader>gt :cs find t <cword><CR>
map <leader>ge :cs find e <cword><CR>
map <leader>gf :cs find f <cword><CR>
map <leader>gi :cs find i <cword><CR>
" special
map <leader>## :!sudo vim %<CR>
map <leader>#w :w !sudo tee %<CR>
" Search support
map <leader>ff :grep <cword> *<CR><C-o>:clist<CR>:cc
map <leader>fr :grep -R <cword> *<CR><C-o>:clist<CR>:cc
map <leader>fn :cnext<CR>
map <leader>fp :cprev<CR>
map <leader>fl :clist<CR>
map <leader>fj :clist<CR>:cc
" signs support
if has('signs')
function! AddSign(name)
execute(":sign place ".line(".")." line=".line(".")." name=".a:name." file=".expand("%:p"))
endfunction
sign define fixme text=!! linehl=Todo texthl=Error
sign define marked text=M linehl=Todo texthl=Todo
sign define dead text=D linehl=Todo texthl=Todo
" signs shortcuts
map <leader>sf :call AddSign("fixme")<CR>
map <leader>sm :call AddSign("marked")<CR>
map <leader>sd :call AddSign("dead")<CR>
map <leader>sx :sign unplace<CR>
end
" cscope support
" use cscope for tagging
set cscopetag
set csto=0
map <C-,>g :cs find g <C-R>=expand("<cword>")<CR><CR>
" TagList support
filetype plugin on
try
map <leader>l :execute 'TlistToggle'<CR>
catch
endtry
" fold to current
map <leader>z :'z,.fo<CR>
" filetype settings
function! ConfigurePython()
setlocal expandtab
setlocal foldmethod=indent
setlocal foldlevel=99
setlocal omnifunc=pythoncomplete#Complete
let g:SuperTabDefaultCompletionType = "context"
endfunction
function! ConfigureC()
setlocal expandtab
endfunction
function! ConfigureMake()
setlocal noexpandtab
endfunction
function! ConfigureHTML()
setlocal tabstop=2
setlocal shiftwidth=2
setlocal softtabstop=2
endfunction
function! ConfigureRuby()
setlocal expandtab
setlocal tabstop=2
setlocal shiftwidth=2
setlocal softtabstop=2
endfunction
function! ConfigureErlang()
setlocal expandtab
setlocal comments=n:%%,n:%
endfunction
function! ConfigureLatex()
setlocal spell
setlocal textwidth=80
endfunction
function! ConfigureVHDL()
setlocal expandtab
setlocal comments=n:--
setlocal tabstop=2
setlocal shiftwidth=2
setlocal softtabstop=2
endfunction
function! ConfigureMatlab()
setlocal expandtab
endfunction
" automagic
autocmd FileType python call ConfigurePython()
autocmd FileType c,cpp call ConfigureC()
autocmd FileType make call ConfigureMake()
autocmd FileType html call ConfigureHTML()
autocmd FileType tex call ConfigureLatex()
autocmd FileType vhdl call ConfigureVHDL()
autocmd FileType ruby call ConfigureRuby()
autocmd FileType erlang call ConfigureErlang()
autocmd FileType matlab call ConfigureMatlab()
" PEP8 checking for Python
let g:pep8_map='<leader>8'
" move swap somewhere more convienient
if RunningWindows()
set directory=$TMP
else
set directory=/home/alex/temp/swap,.,/var/tmp,/tmp
end
" allow us to switch back and forth between 80 column mode and others
let s:std_width = 80
let s:col_width = 80
function! ToggleWidth()
if &columns != s:std_width
let s:col_width = &columns
let &columns = s:std_width
else
let &columns = s:col_width
endif
endfunction
function! Solarize(...)
if a:0 >= 1
let &background=a:1
else
let &background='light'
endif
if a:0 >= 2
let g:solarized_termcolors=a:2
else
let g:solarized_termcolors=16
endif
colorscheme solarized
endfunction
" gui configuration sans .gvimrc
if has('gui_running')
set t_Co=256
" color scheme for gui operation
"let g:moria_style='white'
"colors moria
colors xoria256
" decent default, 86 is way too huge and makes it a pain to position
"set lines=70
" toggle width in GUI window
map <leader>W :call ToggleWidth()<CR>
if RunningWindows()
" windows preferred font
set guifont=Consolas:h9
" set lines to 999 - allow autoscaling of window height
set lines=999
elseif RunningMac()
" mac preferred font
""set guifont=DejaVu\ Sans\ Mono:h11
""set guifont=Bitstream\ Vera\ Sans\ Mono:h12
"set guifont=Inconsolata:h13
set guifont=Anonymous\ Pro:h11
" save a bit of vertical space with Inconsolata
set linespace=-1
call Solarize('dark', 256)
"set lines=85
else
" linux preferred font
set guifont=Bitstream\ Vera\ Sans\ Mono\ 8
end
" use better labels for GUI tabs
set guitablabel=%!expand(\"\%:t\")
" remove the, largely useless, toolbar
set guioptions-=T
else
" color scheme for terminal operation - special case if 256 colors are
" available
if &t_Co == 256
call Solarize('dark')
else
colorscheme desert
endif
call Solarize('dark', 16)
end
" Search for selected text, forwards or backwards.
vnoremap <silent> * :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy/<C-R><C-R>=substitute(
\escape(@", '/\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
vnoremap <silent> # :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy?<C-R><C-R>=substitute(
\escape(@", '?\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
" Copy matches of the last search to a register (default is the clipboard).
" Accepts a range (default is the current line).
" Matches are appended to the register and each match is terminated by \n.
" Usage: [RANGE]CopyMatches [REGISTER]
command! -nargs=0 -range -register CopyMatches call s:CopyMatches(<line1>, <line2>, "<reg>")
function! s:CopyMatches(line1, line2, reg)
let reg = a:reg != '' ? a:reg : '+'
for line in range(a:line1, a:line2)
let txt = getline(line)
let idx = match(txt, @/)
while idx > -1
exec "let @".reg." .= matchstr(txt, @/, idx) . \"\n\""
let end = matchend(txt, @/, idx)
let idx = match(txt, @/, end)
endwhile
endfor
endfunction
" Clear buffer and copy all matches
map <leader>y 0"+y0:g//CopyMatches<CR>
let g:vimwiki_list = [{'path': '~/Dropbox/vimwiki'}]