-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.vimrc.local
More file actions
executable file
·351 lines (284 loc) · 11.1 KB
/
.vimrc.local
File metadata and controls
executable file
·351 lines (284 loc) · 11.1 KB
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
"Auto source file cpp extension
if WINDOWS()
autocmd bufnewfile *.cpp so $HOME\.spf13-vim-3\vim\c_src.txt
else
autocmd bufnewfile *.cpp so $HOME/.spf13-vim-3/vim/c_src.txt
endif
autocmd bufnewfile *.cpp exe "1," . 10 . "g/@file.*/s//@file " .expand("%")
autocmd Bufwritepre,filewritepre *.cpp execute "normal ma"
autocmd bufwritepost,filewritepost *.cpp execute "normal `a"
"Auto source file c extension
if WINDOWS()
autocmd bufnewfile *.c so $HOME\.spf13-vim-3\vim\c_src.txt
else
autocmd bufnewfile *.c so $HOME/.spf13-vim-3/vim/c_src.txt
endif
autocmd bufnewfile *.c exe "1," . 10 . "g/@file.*/s//@file " .expand("%")
autocmd Bufwritepre,filewritepre *.c execute "normal ma"
autocmd bufwritepost,filewritepost *.c execute "normal `a"
"Auto header file h extension
if WINDOWS()
autocmd bufnewfile *.h so $HOME\.spf13-vim-3\vim\c_hdr.txt
else
autocmd bufnewfile *.h so $HOME/.spf13-vim-3/vim/c_hdr.txt
endif
autocmd bufnewfile *.h exe "1," . 10 . "g/@file.*/s//@file " .expand("%")
autocmd bufnewfile *.h exe "1," . 70 . "g/FNAME/s//" .substitute(toupper(expand("%:t")), "\\.", "_", "g")
autocmd Bufwritepre,filewritepre *.h execute "normal ma"
autocmd bufwritepost,filewritepost *.h execute "normal `a"
"Auto text file txt extension
if WINDOWS()
autocmd bufnewfile *.txt so $HOME\.spf13-vim-3\vim\text.txt
else
autocmd bufnewfile *.txt so $HOME/.spf13-vim-3/vim/text.txt
endif
autocmd bufnewfile *.txt exe "1," . 10 . "g/@file.*/s//@file " .expand("%")
autocmd Bufwritepre,filewritepre *.txt execute "normal ma"
autocmd bufwritepost,filewritepost *.txt execute "normal `a"
"Auto scr file scr extension
if WINDOWS()
autocmd bufnewfile *.scr so $HOME\.spf13-vim-3\vim\script.txt
else
autocmd bufnewfile *.scr so $HOME/.spf13-vim-3/vim/script.txt
endif
autocmd bufnewfile *.scr exe "1," . 10 . "g/@file :.*/s//@file : " .expand("%")
autocmd bufnewfile *.scr exe "1," . 10 . "g/@created on :.*/s//@created on : " .strftime("%a, %d %b %Y, %X %z")
autocmd Bufwritepre,filewritepre *.scr execute "normal ma"
autocmd Bufwritepre,filewritepre *.scr exe "1," . 10 . "g/@last modified :.*/s//@last modified : " .strftime("%a, %d %b %Y, %X %z")
autocmd bufwritepost,filewritepost *.scr execute "normal `a"
"Automatic remove trailing whitespaces on save
autocmd BufWritePre *.py :%s/\s\+$//e
" NeoComplete settings
" Set minimum syntax keyword length.
let g:neocomplete#auto_completion_start_length = 1
" Recommended key-mappings.
" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
return neocomplete#close_popup() . "\<CR>"
" For no inserting <CR> key.
"return pumvisible() ? neocomplete#close_popup() : "\<CR>"
endfunction
" <TAB>: completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
"Disable Syntastic
"autocmd VimEnter * SyntasticToggleMode " disable syntastic by default
" Enable neomake
" When writing a buffer.
"call neomake#configure#automake('w')
" When writing a buffer, and on normal mode changes (after 750ms).
"call neomake#configure#automake('nw', 750)
" When reading a buffer (after 1s), and when writing.
"call neomake#configure#automake('rw', 1000)
" ---------------------------------- common after this ---------------------------------
" Set Visual Column marker
set colorcolumn=80
" Highlight column marker and set its color to grey
highlight colorcolumn ctermbg=grey guibg=black
" Set font
set guifont=Andale_Mono:h10,Menlo:h10,Consolas:h10,Courier_New:h10
color zenburn
highlight CursorLine ctermbg=5
highlight CursorLine ctermfg=yellow
" Set nospell
set nospell
"Set tags
"Find tags all the way to root. Will be slow if lot of files. Better option is to set direct path
" in vim :set tags=/path/to/tags
" use :set tags to see current path
set tags=./tags;/
"Automatic Indent on save
"au BufWrite * :Autoformat
" toggle paste
augroup auto_comment
au!
au FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
augroup END
" Provide space in comment /* x */
let NERDSpaceDelims=1
" Set relative numbering when in normal mode and absolute numbering
" in insert mode.
autocmd InsertEnter * :set norelativenumber
autocmd InsertLeave * :set relativenumber
" Change leader for easy motion to <leader> from <leader><leader>
let g:EasyMotion_leader_key='<leader>'
" Exclude following windows from easy motion
let g:numbers_exclude = ['gundo', 'minibufexpl']"
" Function header
function Fhead()
let s:line=line(".")
call setline(s:line,"/**")
call append(s:line," * @brief ")
call append(s:line+1," * @param ")
call append(s:line+2," * @return ")
call append(s:line+3," */")
unlet s:line
endfunction
" Enum/Struct/typedef header
function Enumhead()
let s:line=line(".")
call setline(s:line,"/**")
call append(s:line," * @typedef ")
call append(s:line+1," * @brief ")
call append(s:line+2," */")
unlet s:line
endfunction
" Comment header
function Commenthead()
let s:line=line(".")
call setline(s:line,"/**")
call append(s:line," * @brief ")
call append(s:line+1," */")
unlet s:line
endfunction
" Map delete to F1
function DeleteFile()
call delete(expand('%')) | bdelete!
endfunction
function! s:swap_lines(n1, n2)
let line1 = getline(a:n1)
let line2 = getline(a:n2)
call setline(a:n1, line2)
call setline(a:n2, line1)
endfunction
function! s:swap_up()
let n = line('.')
if n == 1
return
endif
call s:swap_lines(n, n - 1)
exec n - 1
endfunction
function! s:swap_down()
let n = line('.')
if n == line('$')
return
endif
call s:swap_lines(n, n + 1)
exec n + 1
endfunction
" Normal mode
":nmap <F1> <Esc>mz:execute DeleteFile()<CR>`zjA
"ctags
"nmap <F4> :!ctags -R *.* <CR><CR>
"\:set tags=./tags<CR>
"cscope
"nmap <F5> :!cscope -Rb <CR><CR>
"\:cs reset<CR>:cs add cscope.out<CR><CR>
"cscope and ctags
nmap <F5> :!ctags -R *.* <CR>
\:!cscope -Rbq <CR>
\:cs reset<CR>:cs add cscope.out<CR><CR>
" Pressing F6 will put a function header template
:nmap <F6> <Esc>mz:execute Fhead()<CR>`zjA
" Pressing F7 will put a enum header template
:nmap <F7> <Esc>mz:execute Enumhead()<CR>`zjA
" Pressing F8 will put a Comment header template
:nmap <F8> <Esc>mz:execute Commenthead()<CR>`zjA
" UPPERCASE and lowercase conversion
nnoremap g^ gUiW
nnoremap gv guiW
" Go to first and last char of line using H and L
nnoremap H ^
nnoremap L g_
" Use tab instead of % for moving between brackets
nnoremap <tab> %
" Space to toggle folds
nnoremap <Space> za
" Setting paste to take care of indenting when pressing p
:nnoremap p p=`]
" This will interfere with ctrlp plugin actually may not it is in normal
" mode but still disabling it
:nnoremap <leader>p p
" Using leader + keys to do copy/paste from reg a
nmap <leader>c V"ay
nmap <leader>v O<Esc>v"ap
nmap <leader>z o<Esc>j
nmap <leader>x O<Esc>j
nmap <silent>,a ggVG
" Assigning special feature to up down arrow key
"no <Up> ddkP
"no <Down> ddp
"nnoremap <Down> :m .+1<CR>==
"nnoremap <Up> :m .-2<CR>==
noremap <silent> <Up> :call <SID>swap_up()<CR>
noremap <silent> <Down> :call <SID>swap_down()<CR>
noremap <Left> yy<Esc>P
noremap <Right> o<Esc>k
"Visual mode
vnoremap <tab> %
vnoremap <Space> za
vnoremap H ^
vnoremap L g_
" Using leader + keys to do copy into a register (yiw)
vnoremap <leader>c "ay
vnoremap <leader>v "ap
vnoremap <leader>x "ad
vnoremap <Down> :m '>+1<CR>gv=gv
vnoremap <Up> :m '<-2<CR>gv=gv
vnoremap <Left> <NOP>
vnoremap <Right> "ap
"Insert mode
" Escape from brackets , pressing ctrl + j will move out of bracket
" in insert mode
inoremap <C-j> <Esc>/[)}"'\]>]<CR>:nohl<CR>a
inoremap <leader><leader> <Esc>/[)}"'\]>]<CR>:nohl<CR>a
inoremap ;; <Esc>$a;
inoremap :: <Esc>$a:<CR>
inoremap .. <Esc>$a<CR>
"inoremap ^^ <NOP>
"inoremap ~~ <NOP>
"inoremap `` <NOP>
"inoremap <silent><Up> <Esc>$a{<CR>}<Esc>O<tab>
"inoremap <silent><Down> <Esc>A<CR>{<CR>}<Esc>O
inoremap <silent><Up> <NOP>
inoremap <silent><Down> <NOP>
inoremap <silent><Left> <Esc>yyPj
inoremap <silent><Right> <NOP>
"cscope settings
if has("cscope")
" use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
set cscopetag
" check cscope for definition of a symbol before checking ctags: set to 1
" if you want the reverse search order.
set csto=0
" add any cscope database in current directory
if filereadable("cscope.out")
cs add cscope.out
" else add the database pointed to by environment variable
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
" show msg when any other cscope db added
"set cscopeverbose
set nocscopeverbose
"Set cscope paths relative to cscope.out
set cscoperelative
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>
nmap <C-@>s :scs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>g :scs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>c :scs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>t :scs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>e :scs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>f :scs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-@>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-@>d :scs find d <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>s :vert scs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>g :vert scs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>c :vert scs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>t :vert scs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>e :vert scs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>f :vert scs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-@><C-@>i :vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-@><C-@>d :vert scs find d <C-R>=expand("<cword>")<CR><CR>
endif