-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.vimrc
executable file
·428 lines (391 loc) · 11.3 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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
set nocp
set backspace=indent,eol,start
set t_Co=256
set mouse=a
syntax enable
filetype plugin on
"set mouse=a
set selection=inclusive
set hlsearch
set expandtab
set smarttab
set autoread
set incsearch
"set so=7
set tabstop=4
set autoindent shiftwidth=4
set smartindent
set wrap
"set autochdir
set cindent
set cino=g0to(sus
set ignorecase
set shiftwidth=4
set iskeyword+=_,$,@,%,#
set ambiwidth=single
" use system clipboard
set clipboard=unnamedplus
map n <C-b>
"
let mapleader=","
map <silent><leader>w : w<cr>
map <silent><leader>qa : qa<cr>
map <silent><leader>qq : q!<cr>
map <silent><leader>wq : wq<cr>
map <silent><leader>q : q<cr>
map <silent><leader>s :source /home/listar/.vimrc <cr>
"Taglist
map <silent><leader>tl :TlistToggle<cr>
let Tlist_Ctags_Cmd = '/usr/bin/ctags'
let Tlist_Show_One_File = 1
let Tlist_Exit_OnlyWindow = 1
let Tlist_Use_Right_Window = 1
let &termencoding=&encoding
set fileencodings=utf-8,cp936,ucs-bom,gbk
"set fileencoding=cp936
set fileencoding=utf-8
"set encoding=cp936
set encoding=utf-8
" cscope
if has("cscope")
set csprg=/usr/bin/cscope
set csto=1
set cst
set nocsverb
" add any database in current directory
if filereadable("cscope.out")
cs add cscope.out
endif
set csverb
endif
nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>
" bufexploer
map <silent><leader>be :BufExplorer<cr>
map <silent><leader>bs :BufExplorerHorizontalSplit<cr>
map <silent><leader>bv :BufExplorerVerticalSplit<cr>
" quickfix
nmap <F6> :cn<cr>
nmap <F7> :cp<cr>
"nmap <F5> :make<cr>
nmap <F8> :cw<cr>
" select all && copy
map <C-a> ggVG
"map <C-c> "+y
"map <C-v> "+p
" press control + s to save
"imap <C-c> <ESC> :w<cr>
"nmap <C-c> <ESC> :w<cr>
" quick jump between splits
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
map <C-h> <C-w>h
" NERD_tree
map <silent><leader>t :NERDTreeToggle<cr>
" another explorer
map <silent><leader>e :Ex<cr>
" only one window
"map <silent><leader>m :only<cr>
" A.vim
map <silent><leader>a :A<cr>
" omnicppcomplete
set completeopt=menu
let OmniCpp_SelectFirstItem = 0
map <F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
set tags+=/home/listar/cppstltags
" pydiction
let g:pydiction_location = '/home/listar/.vim/tools/pydiction/complete-dict'
"php set
"au FileType php source /usr/share/vim/vim72/colors/murphy.vim
let g:phpColor = "murphy"
let g:defaultColor = "desert"
"au! FileType * exe ":colorscheme " . g:defaultColor
"au! FileType php exe ":colorscheme " . g:phpColor
" neocomplcache
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplcache.
let g:neocomplcache_enable_at_startup = 1
" don't auto select for me
let g:neocomplcache_enable_auto_select = 0
" Use smartcase.
let g:neocomplcache_enable_smart_case = 1
" don't popup the completion list
let g:neocomplcache_disable_auto_complete = 1
" Use camel case completion.
let g:neocomplcache_enable_camel_case_completion = 1
" Use underbar completion.
let g:neocomplcache_enable_underbar_completion = 1
" Ignore case
let g:neocomplcache_enable_ignore_case = 1
" Set minimum syntax keyword length.
let g:neocomplcache_min_syntax_length = 3
let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'
" let supertab use tab to complete
let g:SuperTabDefaultCompletionType = "<c-x><c-u>"
" code_complete
let g:completekey="<c-j>"
"colorscheme desert256
syntax enable
filetype plugin on
"hi normal ctermbg=black
"imap jj <ESC>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if(has("win32") || has("win95") || has("win64") || has("win16"))
let g:iswindows=1
else
let g:iswindows=0
endif
"单个文件编译
map <F5> :call Do_OneFileMake()<CR>
function Do_OneFileMake()
if expand("%:p:h")!=getcwd()
echohl WarningMsg | echo "Fail to make! This file is not in the current dir! Press <F7> to redirect to the dir of this file." | echohl None
return
endif
let sourcefileename=expand("%:t")
if (sourcefileename=="" || (&filetype!="cpp" && &filetype!="c"))
echohl WarningMsg | echo "Fail to make! Please select the right file!" | echohl None
return
endif
let deletedspacefilename=substitute(sourcefileename,' ','','g')
if strlen(deletedspacefilename)!=strlen(sourcefileename)
echohl WarningMsg | echo "Fail to make! Please delete the spaces in the filename!" | echohl None
return
endif
if &filetype=="c"
if g:iswindows==1
set makeprg=gcc\ -g\ -o\ %<.exe\ %
else
set makeprg=gcc\ -g\ -std=c99\ -o\ %<\ %
endif
elseif &filetype=="cpp"
if g:iswindows==1
set makeprg=g++\ -g\ -o\ %<.exe\ %
else
set makeprg=g++\ -g\ -o\ %<\ %
endif
"elseif &filetype=="cs"
"set makeprg=csc\ \/nologo\ \/out:%<.exe\ %
endif
if(g:iswindows==1)
let outfilename=substitute(sourcefileename,'\(\.[^.]*\)$','.exe','g')
let toexename=outfilename
else
let outfilename=substitute(sourcefileename,'\(\.[^.]*\)$','','g')
let toexename=outfilename
endif
if filereadable(outfilename)
if(g:iswindows==1)
let outdeletedsuccess=delete(getcwd()."\\".outfilename)
else
let outdeletedsuccess=delete("./".outfilename)
endif
if(outdeletedsuccess!=0)
set makeprg=make
echohl WarningMsg | echo "Fail to make! I cannot delete the ".outfilename | echohl None
return
endif
endif
execute "silent make"
set makeprg=make
execute "normal :"
if filereadable(outfilename)
if(g:iswindows==1)
execute "!".toexename
else
execute "!./".toexename
endif
else
execute "copen"
endif
redraw!
endfunction
"进行make的设置
"map <F6> :call Do_make()<CR>
"map <c-F6> :silent make clean<CR>
function Do_make()
set makeprg=make
execute "silent make"
execute "copen"
endfunction
map <F9> :set paste<CR>
map <F10> :set nopaste<CR>
" behave like mswin
"source $VIMRUNTIME/mswin.vim
"behave mswin
" session and viminfo
"au VimLeave * mksession! ~/.vim/session/%:t.session
"au VimLeave * wviminfo! ~/.vim/session/%:t.viminfo
" vim template
autocmd BufNewFile *.cpp 0 r ~/.vim/template/cpp.tpl
autocmd BufNewFile *.c 0 r ~/.vim/template/gnuc.tpl
autocmd BufNewFile *.py 0 r ~/.vim/template/python.tpl
" minibufexpl.vim
"let g:miniBufExplMapWindowNavVim=1
"let g:miniBufExplMapWindowNavArrows=1
"let g:miniBufExplMapCTabSwitchBufs=1
"let g:miniBufExplModSelTarget=1
" <tag> autocomplete
function! InsertHtmlTag()
let pat = '\c<\w\+\s*\(\s\+\w\+\s*=\s*[''#$;,()."a-z0-9]\+\)*\s*>'
normal! a>
let save_cursor = getpos('.')
let result = matchstr(getline(save_cursor[1]), pat)
if (search(pat, 'b', save_cursor[1]))
normal! lyiwf>
normal! a</
normal! p
normal! a>
endif
:call cursor(save_cursor[1], save_cursor[2], save_cursor[3])
endfunction
inoremap > <ESC>:call InsertHtmlTag()<CR>a
" html indent setting
au FileType html,python,vim,javascript setl shiftwidth=4
au FileType html,python,vim,javascript setl tabstop=4
" mark.vim
"source ~/.vim/plugin/mark.vim
" change the cursor shape
"if has("autocmd")
"au InsertEnter * silent execute "!gconftool-2 --type string --set /apps/gnome-terminal/profiles/Default/cursor_shape ibeam"
"au InsertLeave * silent execute "!gconftool-2 --type string --set /apps/gnome-terminal/profiles/Default/cursor_shape block"
"au VimLeave * silent execute "!gconftool-2 --type string --set /apps/gnome-terminal/profiles/Default/cursor_shape ibeam"
"endif
" settings of cscope.
" I use GNU global instead cscope because global is faster.
"set cscopetag
"set cscopeprg=gtags-cscope
set cscopequickfix=c-,d-,e-,f-,g0,i-,s-,t-
nmap <silent> <leader>j <ESC>:cstag <c-r><c-w><CR>
nmap <silent> <leader>g <ESC>:lcs f c <c-r><c-w><cr>:lw<cr>
nmap <silent> <leader>s <ESC>:lcs f s <c-r><c-w><cr>:lw<cr>
command! -nargs=+ -complete=dir FindFiles :call FindFiles(<f-args>)
au VimEnter * call VimEnterCallback()
"au BufAdd *.[ch],*.cpp call FindGtags(expand('<afile>'))
au BufWritePost *.[ch],*.cpp call UpdateGtags(expand('<afile>'))
function! FindFiles(pat, ...)
let path = ''
for str in a:000
let path .= str . ','
endfor
if path == ''
let path = &path
endif
echo 'finding...'
redraw
call append(line('$'), split(globpath(path, a:pat), '\n'))
echo 'finding...done!'
redraw
endfunc
function! VimEnterCallback()
for f in argv()
if fnamemodify(f, ':e') != 'c' && fnamemodify(f, ':e') != 'h'
continue
endif
call FindGtags(f)
endfor
endfunc
function! FindGtags(f)
let dir = fnamemodify(a:f, ':p:h')
while 1
let tmp = dir . '/GTAGS'
if filereadable(tmp)
silent exe 'cs kill -1'
exe 'cs add ' . tmp . ' ' . dir
break
elseif dir == '/'
break
endif
let dir = fnamemodify(dir, ":h")
endwhile
endfunc
function! UpdateGtags(f)
let dir = fnamemodify(a:f, ':p:h')
exe 'silent !cd ' . dir . ' && global -u &> /dev/null &'
endfunction
map <F2> :call FindGtags(expand('<afile>'))<CR>
"if filereadable("GTAGS")
"silent exe 'cs add GTAGS'
"endif
" abbre
abbre em [email protected]
" astyle
map <S-F> <Esc>:%! astyle<CR>
" large.vim
let g:LargeFile=50
" easymotion
let g:EasyMotion_leader_key = ';'
let g:solarized_termcolors=256
"set background=dark
"colorscheme solarized
"colorscheme desert256
let g:molokai_original=0
colorscheme molokai
"colorscheme murphy
" auto load tags
function! AutoLoadCTagsAndCScope()
let max = 15
let dir = getcwd()
let i = 0
let break = 0
while isdirectory(dir) && i < max
if filereadable(dir . '/cscope.out')
execute 'cs add ' . dir . '/cscope.out'
let break = 1
endif
if filereadable(dir . '/tags')
execute 'set tags =' . dir . '/tags'
let break = 1
endif
if break == 1
"execute 'lcd ' . dir
break
endif
let dir = strpart(dir, 0, strridx(dir, "/"))
let i = i + 1
endwhile
endf
nmap <F7> :call AutoLoadCTagsAndCScope()<CR>
" vundle
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle
" required!
Plugin 'gmarik/vundle'
" My Bundles here:
"
" original repos on github
"Bundle 'tpope/vim-fugitive'
"Bundle 'Lokaltog/vim-easymotion'
"Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
"Bundle 'tpope/vim-rails.git'
" vim-scripts repos
Plugin 'L9'
Plugin 'FuzzyFinder'
Plugin 'wting/rust.vim'
Plugin 'Valloric/YouCompleteMe'
Plugin 'mileszs/ack.vim'
Plugin 'fatih/vim-go'
" non github repos
"Bundle 'git://git.wincent.com/command-t.git'
call vundle#end()
filetype plugin indent on " required!
" see :h vundle for more details or wiki for FAQ
" NOTE: comments after Bundle command are not allowed..
" syntastic
"call pathogen#infect()
" ycm
let g:ycm_global_ycm_extra_conf = '/home/listar/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py'
" ack & ag
let g:ackprg = 'ag --nogroup --column'
let g:ycm_max_diagnostics_to_display = 0