-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvimrc
564 lines (449 loc) · 13.6 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
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" _
" __ | \
" / | /
" \__ | \
" by Amix - http://amix.dk/
"
" Maintainer: Amir Salihefendic <amix3k at gmail.com>
" Version: 2.7
" Last Change: 12/10/06 00:09:21
"
" Sections:
" ----------------------
" General
" Colors and Fonts
" Fileformats
" VIM userinterface
" Statusline
" Visual
" Moving around and tabs
" General Autocommands
" Parenthesis/bracket expanding
" General Abbrevs
" Editing mappings etc.
" Command-line config
" Buffer related
" Files and backups
" Folding
" Text options
" Indent
" Spell checking
" Plugin configuration
" Yank ring
" File explorer
" Minibuffer
" Tag list (ctags) - not used
" LaTeX Suite things
" Filetype generic
" Todo
" Text
" VIM
" XML
" HTML related
" Ruby & PHP section
" Python section
" Cheetah section
" Vim section
" Java section
" JavaScript section
" C mappings
" SML
" Scheme bindings
" Tex
" Snippets
" Python
" javaScript
" Cope
" Macros
" MISC
"
" Tip:
" If you find anything that you can't understand than do this:
" help keyword OR helpgrep keywords
" Example:
" Go into command-line mode and type helpgrep nocompatible, ie.
" :helpgrep nocompatible
" then press <leader>c to see the results, or :botright cw
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Get out of VI's compatible mode..
set nocompatible
"Sets how many lines of history VIM har to remember
set history=400
"Set auto backup
set nobackup
set shiftwidth=8
"Set dictionary complete
set dictionary=/usr/share/dict/American-english,/usr/share/dict/british-english,~/.words.utf-8.add
"Enable filetype plugin
filetype plugin on
filetype indent on
"Set to auto read when a file is changed from the outside
set autoread
"Set auto write when a file is modified
set autowriteall
"Have the mouse enabled all the time:
set mouse=a
"Set mapleader
let mapleader = ","
let g:mapleader = ","
"Fast saving
nmap <leader>w :w!<cr>
"Fast reloading of the .vimrc
map <leader>s :source ~/.vimrc<cr>
"Fast editing of .vimrc
map <leader>e :e! ~/.vimrc<cr>
"When .vimrc is edited, reload it
autocmd! bufwritepost ~/.vimrc :source ~/.vimrc
autocmd BufNewFile,BufRead ~/.vimrc :set shiftwidth=4
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Enable syntax hl
syntax enable
set gfn=fixed
if has("gui_running")
set guioptions-=T
let psc_style='cool'
colorscheme torte
else
set background=dark
"colorscheme zellner
"colorscheme peachpuff
"colorscheme pablo
"colorscheme torte
endif
autocmd BufEnter * :syntax sync fromstart
"Highlight current
if has("gui_running")
set cursorline
hi cursorline guibg=#333333
hi CursorColumn guibg=#333333
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Fileformats
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Favorite filetype
set fileformats=unix,dos
"Set favorite character encodings
set fileencodings=utf-8,gbk
"Set internal encoding
set encoding=utf8
"Set terminal encoding (for keyboard inputs and display)
set termencoding=utf8
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" VIM userinterface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Use English lanuage for messages
:language C
"Set 5 lines to the cursors - when moving vertical..
set so=5
"Turn on Wild menu
set wildmenu
"Always show current position
set ruler
"Show (partial) command in the last line of the screen
set showcmd
"The commandbar is 1 high
set cmdheight=1
"Show line number
set nu
"Do not redraw, when running macros.. lazyredraw
set lz
"Change buffer - without saving
set hid
"Set backspace
set backspace=eol,start,indent
"Backspace and cursor keys wrap to
set whichwrap+=<,>
"Ignore case when searching
set ignorecase
set smartcase
"Set magic on
set magic
"No sound on errors.
set noerrorbells
set novisualbell
set vb t_vb=
"show matching brackets
set showmatch
"How many tenths of a second to blink
set mat=2
"Increment search
set incsearch
"Highlight search things
set hlsearch
""""""""""""""""""""""""""""""
" Statusline
""""""""""""""""""""""""""""""
"Always hide the status line
set laststatus=2
"Format the Statusline
set statusline=\ %F%m%r%h\ %w\ \ CWD:\ %{getcwd()}%=%-20.(Line:\ %l/%L:%c%)%-.(--%p%%--\ \ %)
""""""""""""""""""""""""""""""
" Visual
""""""""""""""""""""""""""""""
" From an idea by Michael Naumann
"function! VisualSearch(direction) range
" let l:saved_reg = @"
" execute "normal! vgvy"
" let l:pattern = escape(@", '\\/.*$^~[]')
" let l:pattern = substitute(l:pattern, "\n$", "", "")
" if a:direction == 'b'
" execute "normal ?" . l:pattern . "^M"
" else
" execute "normal /" . l:pattern . "^M"
" endif
" let @/ = l:pattern
" let @" = l:saved_reg
"endfunction
"
""Basically you press * or # to search for the current selection !! Really useful
"vnoremap <silent> * :call VisualSearch('f')<CR>
"vnoremap <silent> # :call VisualSearch('b')<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Moving around and tabs
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Map space to : and c-space to ?
map <space> :
"map <c-space> ?
"smart way to move btw. windows
"map <S-j> <C-W><C-W><C-Y><C-W><C-W>
"map <S-k> <C-W><C-W><C-E><C-W><C-W>
"Actually, the tab does not switch buffers, but my arrows
"Bclose function can be found in "Buffer related" section
map <leader>bd :Bclose<cr>
"Use the arrows to something useful
map <up> :bn<cr>
map <down> :bp<cr>
"Tab configuration
map <leader>tn :tabnew<cr>
map <leader>te :tabedit
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
nmap <right> :tabnext<cr>
nmap <left> :tabNext<cr>
try
set switchbuf=usetab
set showtabline=2
catch
endtry
"maintain the horizontal cursor position when
"scrolling with the <Page Up>, <Page Down>, etc keys
set nostartofline
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" General Autocommands
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
autocmd FileType c,cpp,h :set cindent
autocmd FileType lisp,scheme :set lisp
"Switch to current dir
map <leader>cd :cd %:p:h<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" General Abbrevs
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"My information
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Editing mappings etc.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Move a line of text using control
"nmap <M-k> mz:m-2<cr>`z
"nmap <M-j> mz:m+<cr>`z
"vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
"vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
"Set a comma separated list of options for Insert mode completion
set completeopt=menu
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Command-line maps
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Bash like
cnoremap <C-A> <Home>
cnoremap <C-E> <End>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Buffer related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Kill buffer
nmap <C-K> :q<cr>
"Restore cursor to file position in previous editing session
set viminfo='10,\"100,:20,%,n~/.viminfo
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
" Don't close window, when deleting a buffer
command! Bclose call <SID>BufcloseCloseIt()
function! <SID>BufcloseCloseIt()
let l:currentBufNum = bufnr("%")
let l:alternateBufNum = bufnr("#")
if buflisted(l:alternateBufNum)
buffer #
else
bnext
endif
if bufnr("%") == l:currentBufNum
new
endif
if buflisted(l:currentBufNum)
execute("bdelete! ".l:currentBufNum)
endif
endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Files and backups
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Turn backup on
set nobackup
set wb
set noswapfile
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Folding
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Text options
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set expandtab
set shiftwidth=4
set tabstop=4
set smarttab
set nolinebreak
set textwidth=0
set wrapmargin=0
set formatoptions+=n2mB
""""""""""""""""""""""""""""""
" Indent
""""""""""""""""""""""""""""""
"Auto indent
set autoindent
"Smart indent
set smartindent
"C-style indenting
set cindent
"Wrap lines
set wrap
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Spell checking
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Set spell on
nmap <F4> :set spell spelllang=en_us<cr>
nmap <F5> :set nospell<cr>
set spellfile=~/.words.utf-8.add
map <leader>sn ]s
map <leader>sp [s
map <leader>sa zg
map <leader>s? z=
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugin configuration
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""
" Vim Grep
""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""
" Yank Ring
""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""
" File explorer
""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""
" Minibuffer
""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""
" Tag list (ctags) - not used
""""""""""""""""""""""""""""""
"let Tlist_Ctags_Cmd = "/sw/bin/ctags-exuberant"
"let Tlist_Sort_Type = "name"
"let Tlist_Show_Menu = 1
"map <leader>t :Tlist<cr>
""""""""""""""""""""""""""""""
" LaTeX Suite things
""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Filetype generic
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Todo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"au BufNewFile,BufRead *.todo so ~/vim_local/syntax/amido.vim
""""""""""""""""""""""""""""""
" Text
""""""""""""""""""""""""""""""
autocmd BufNewFile,BufRead *.txt :set filetype=text
autocmd FileType text :nnoremap <buffer> <leader>f mzgggqG`z
""""""""""""""""""""""""""""""
" VIM
""""""""""""""""""""""""""""""
" autocmd FileType vim map <buffer> <leader><space> :w!<cr>:source %<cr>
""""""""""""""""""""""""""""""
" XML
""""""""""""""""""""""""""""""
autocmd FileType xml set shiftwidth=4
autocmd FileType xml set tabstop=4
""""""""""""""""""""""""""""""
" HTML related
""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""
" Java section
"""""""""""""""""""""""""""""""
au FileType java inoremap <buffer> <C-t> System.out.println();<esc>hi
autocmd FileType java :nmap <buffer> <leader>f :%!indent<cr>
"Java comments
"autocmd FileType java source ~/vim_local/macros/jcommenter.vim
autocmd FileType java let b:jcommenter_class_author='Íõ±ø±ø ([email protected])'
autocmd FileType java let b:jcommenter_file_author='Íõ±ø±ø ([email protected])'
autocmd FileType java map <buffer> <F2> :call JCommentWriter()<cr>
"Abbr'z
""""""""""""""""""""""""""""""
" HTML
"""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""
" C mappings
"""""""""""""""""""""""""""""""
"map external program `indent' to <leader>f
autocmd FileType c :nmap <buffer> <leader>f :%!indent<cr>
autocmd FileType c :set shiftwidth=4
autocmd FileType c :set tabstop=4
autocmd FileType c :set expandtab
autocmd FileType c,cpp :set tw=70
""""""""""""""""""""""""""""""
" Scheme bindings
""""""""""""""""""""""""""""""
" autocmd BufNewFile,BufRead *.scm map <buffer> <leader><space> <leader>cd:w<cr>:!petite %<cr>
" autocmd BufNewFile,BufRead *.scm inoremap <buffer> <C-t> (pretty-print )<esc>i
" autocmd BufNewFile,BufRead *.scm vnoremap <C-t> <esc>`>a)<esc>`<i(pretty-print <esc>
autocmd FileType scheme :nnoremap <buffer> <leader>f mzgg=G`z
autocmd FileType scheme :inoremap <buffer> <CR> <CR><ESC>cc
autocmd FileType scheme :nnoremap <buffer> o o<ESC>cc
autocmd FileType scheme :nnoremap <buffer> O O<ESC>cc
"""""""""""""""""""""""""""""
" Tex autocmd
"""""""""""""""""""""""""""""
autocmd BufNewFile *.tex :normal gg0i\input{/home/wbb/Books/latex/macro.tex}
autocmd BufNewFIle *.tex :set fenc=gbk
"""""""""""""""""""""""""""""
" Mutt autocmd
"""""""""""""""""""""""""""""
autocmd BufRead /tmp/mutt-* set textwidth=72
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Cope
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"For Cope
"map <silent> <leader><cr> :noh<cr>
"Original for all
"map <leader>n :cn<cr>
"map <leader>p :cp<cr>
"map <leader>c :botright cw 10<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Macros
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Use '\K' to see man page of the keyword under the cursor
:runtime! ftplugin/man.vim
"Use '_j' to format the selected text block
:runtime macros/justify.vim
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" MISC
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Remove the Windows ^M
noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
" Paste current date
nmap <leader>d a<c-r>=strftime("%Y-%m-%d")<cr><ESC>
"Paste toggle - when pasting something in, don't indent.
set pastetoggle=<F3>
"Remove indenting on empty lines
map <F2> :%s/\s*$//g<cr>:noh<cr>