-
Notifications
You must be signed in to change notification settings - Fork 2
/
vimrc
778 lines (634 loc) · 21.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
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
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
" 通用设置
" 请手动设置当前系统,参数为:mac,linux,windows
" fun! MySys( )
" return "$1"
" endfun
" set runtimepath=~/.vim,~/.vim/after,\$VIMRUNTIME
" source ~/.vim/vimrc
" helptags ~/.vim/doc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sets how many lines of history VIM has to remember
" 设置VIM记录多少条历史命令
set history=700
" Enable filetype plugin
" 激活filetype插件
filetype plugin on
filetype indent on
" Set to auto read when a file is changed from the outside
" 设置当文件改变时自动读取
set autoread
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
" 设置组合键的默认快捷键,此处设置的默认快捷键是","(即英文字母M旁边的逗号按键 )
let mapleader = ","
let g:mapleader = ","
" Fast saving
" 设置快速保存快捷键为 ,w
nmap <leader>w :w!<cr>
" Fast quit
" 设置快速退出快捷键为 ,q
nmap <leader>q :q<cr>
" Fast editing of the .vimrc
" 设置快读编辑vimrc文件的快捷键为 ,ee
map <leader>ee :e! ~/.vim/vimrc<cr>
" When vimrc is edited, reload it
" 当vimrc文件被编辑时,自动重新加载
autocmd! bufwritepost vimrc source ~/.vim/vimrc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM user interface
" VIM 用户界面设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set 7 lines to the curors - when moving vertical..
set so=10
" Trun on Wild menu
" wildmenu' 打开时,命令行补全以增强模式运行。按下 'wildchar' ( 通常是<Tab>) 启动补全。
set wildmenu
" Always show current position
" 会在状态列显示光标所在处的行列状态
set ruler
" The commandbar height
" 将命令行设置成为两行
set cmdheight=2
" Change buffer - without saving
" 允许在有未保存的修改时切换缓冲区,此时的修改由切换由 vim 负责保存
set hid
" Set backspace config
" 不设定的话在插入状态无法用退格键和 Delete
set backspace=eol,start,indent
"
" 默认情况下, 在 VIM 中当光标移到一行最左边的时候, 继续按左键,光标不能回到上一行的最右边。
" 通过设置 whichwrap 可以对一部分按键开启这项功能。可以把需要开启的键的代号写到 whichwrap 的参数列表中。
set whichwrap+=<,> ",h,l 我个人不习惯,故注释掉
" Ignore case when searching
" 搜索时忽略大小写
set ignorecase
" 搜索时,如果有一个或以上大写字母时,仍保持对大小写敏感"
set smartcase
" Highlight search things
" 搜索时符合的字符串会反白高亮显示
set hlsearch
" Make search act like search in modern browsers
" 设置搜索时一边输入一边显示效果
set incsearch
" Don't redraw while executing macros
" 对于慢终端( slowterminal)我们可以使用lazyredraw选项.他可以阻止Vim在宏中部重绘屏幕 )
set nolazyredraw
" Set magic on, for regular expressions
" magic就是设置哪些元字符要加反斜杠哪些不用加的。简单来说:
" magic( \m):除了 $ . * ^ 之外其他元字符都要加反斜杠。
" nomagic( \M):除了 $ ^ 之外其他元字符都要加反斜杠。 ))
set magic
" Show matching bracets when text indicator is over them
" 设置匹配模式,类似当输入一个左括号时会匹配相应的那个右括号
set showmatch
" How many tenths of a second to blink
" debug 有多少十分之一秒闪烁
set mat=2
" No sound on errors
" 报错时不发出声音
set noerrorbells
set novisualbell
set t_vb=
set tm=500
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
" 色彩和字体设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable syntax hl
" 打开语法高亮
syntax enable
" Set font according to system
" 根据系统设置字体
if MySys() == "mac"
set gfn=Menlo:h12
set shell=/bin/bash
elseif MySys() == "windows"
set gfn=Bitstream\ Vera\ Sans\ Mono:h10
elseif MySys() == "linux"
set gfn=Monospace\ 9
set shell=/bin/bash
endif
if has("gui_running")
set guioptions-=T
set t_Co=256
set background=dark
colorscheme peaksea
set nu
else
colorscheme zellner
set background=dark
set nu
endif
try
lang en_US
catch
endtry
" Default file types
" 设置默认文件类型
set fileformats=unix,dos,mac
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Encoding
" 编码相关
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set fileencoding=utf-8
set fileencodings=utf-8,gb18030,ucs-bom,gbk,gb2312,cp936
set encoding=utf8
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
" 文件、备份、撤销相关
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git anyway...
" 关闭备份
set nobackup
set nowb
set noswapfile
" Persistent undo
" 卸载缓冲区时,Vim 通常会删除该缓冲区建立的撤销树。通过设置 'undofile' 选项,
" Vim 会在写入文件时自动保存撤销历史,而重新编辑文件时,恢复撤销历史。
try
if MySys() == "windows"
set undodir=C:\Windows\Temp
else
set undodir=~/.vim/tempfiledir
endif
set undofile
catch
endtry
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
" 文本、tab、缩进设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 切换是否进入粘贴模式
map <leader>fp :set paste<cr>
map <leader>fi :set nopaste<cr>
" 插入模式里: 插入 <Tab> 时使用合适数量的空格
" set expandtab
" 缩进每一步使用的空白数目
set shiftwidth=4
" 文件里的 <Tab> 代表的空格数
set tabstop=4
" 行首的 <Tab> 根据 'shiftwidth' 插入空白''
" set smarttab
" Vim在合适的地方折行
set linebreak
" 不希望在下划线处打断句子
set breakat-=_
" 插入文本的最大宽度。更长的行会在空白之后截断,以达到此宽度
set tw=1000
" 开启新行时,从当前行复制缩进距离。
set ai
set si "Smart indet
"该选项改变文本显示的方式。它不改变缓冲区里的文本,'textwidth' 会。如果打开,超过窗口宽度的行会回绕,并在下一行继续显示。
set wrap "Wrap lines
""""""""""""""""""""""""""""""
" => Visual mode related
" 可视模式相关
""""""""""""""""""""""""""""""
" Really useful!
" In visual mode when you press * or # to search for the current selection
vnoremap <silent> * :call VisualSearch('f')<CR>
vnoremap <silent> # :call VisualSearch('b')<CR>
" When you press gv you vimgrep after the selected text
vnoremap <silent> gv :call VisualSearch('gv')<CR>
map <leader>g :vimgrep // **/*.<left><left><left><left><left><left><left>
function! CmdLine(str)
exe "menu Foo.Bar :" . a:str
emenu Foo.Bar
unmenu Foo
endfunction
" 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"
elseif a:direction == 'gv'
call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.')
elseif a:direction == 'f'
execute "normal /" . l:pattern . "^M"
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Command mode related
" 命令模式相关
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Smart mappings on the command line
cno $h e ~/
cno $d e ~/Desktop/
cno $j e ./
cno $c e <C-\>eCurrentFileDir("e")<cr>
" $q is super useful when browsing on the command line
cno $q <C-\>eDeleteTillSlash()<cr>
" Bash like keys for the command line
cnoremap <C-A> <Home>
cnoremap <C-E> <End>
cnoremap <C-K> <C-U>
cnoremap <C-P> <Up>
cnoremap <C-N> <Down>
" Useful on some European keyboards
map ½ $
imap ½ $
vmap ½ $
cmap ½ $
func! Cwd()
let cwd = getcwd()
return "e " . cwd
endfunc
func! DeleteTillSlash()
let g:cmd = getcmdline()
if MySys() == "linux" || MySys() == "mac"
let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*", "\\1", "")
else
let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\]\\).*", "\\1", "")
endif
if g:cmd == g:cmd_edited
if MySys() == "linux" || MySys() == "mac"
let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*/", "\\1", "")
else
let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\\]\\).*\[\\\\\]", "\\1", "")
endif
endif
return g:cmd_edited
endfunc
func! CurrentFileDir(cmd)
return a:cmd . " " . expand("%:p:h") . "/"
endfunc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Moving around, tabs and buffers
" 移动、制表符、缓冲相关
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Map space to / (search) and c-space to ? (backgwards search)
map <space> /
map <c-space> ?
map <silent> <leader><cr> :noh<cr>
" Smart way to move btw. windows
" 窗口分割时,进行切换的按键热键需要连接两次,比如从下方窗口移动光标到上方窗口,需要<c-w><c-w>k,现在重映射为<c-k>,切换的时候会变得非常方便。
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Close all the buffers
map <leader>ba :1,300 bd!<cr>
" Use the arrows to something usefull
map <right> :bn<cr>
map <left> :bp<cr>
" Tab configuration
map <leader>tn :tabnew<cr>
map <leader>te :tabedit
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
" When pressing <leader>cd switch to the directory of the open buffer
map <leader>cd :cd %:p:h<cr>
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
" Specify the behavior when switching between buffers
try
set switchbuf=usetab
set stal=2
catch
endtry
""""""""""""""""""""""""""""""
" => Statusline
" 状态行
""""""""""""""""""""""""""""""
" Always hide the statusline
set laststatus=2
" Format the statusline
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c
function! CurDir()
let curdir = substitute(getcwd(), '/Users/kimi/', "~/", "g")
return curdir
endfunction
function! HasPaste()
if &paste
return 'PASTE MODE '
else
return ''
endif
endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Parenthesis/bracket expanding
" 括号等
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
vnoremap $1 <esc>`>a)<esc>`<i(<esc>
vnoremap $2 <esc>`>a]<esc>`<i[<esc>
vnoremap $3 <esc>`>a}<esc>`<i{<esc>
vnoremap $$ <esc>`>a"<esc>`<i"<esc>
vnoremap $q <esc>`>a'<esc>`<i'<esc>
vnoremap $e <esc>`>a"<esc>`<i"<esc>
" Map auto complete of (, ", ', [
inoremap $1 ()<esc>i
inoremap $2 []<esc>i
inoremap $3 {}<esc>i
inoremap $4 {<esc>o}<esc>O
inoremap $q ''<esc>i
inoremap $e ""<esc>i
inoremap $t <><esc>i
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General Abbrevs
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
iab xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Editing mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Remap VIM 0
map 0 ^
"Move a line of text using ALT+[jk] or Comamnd+[jk] on mac
nmap <M-j> mz:m+<cr>`z
nmap <M-k> mz:m-2<cr>`z
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
if MySys() == "mac"
nmap <D-j> <M-j>
nmap <D-k> <M-k>
vmap <D-j> <M-j>
vmap <D-k> <M-k>
endif
"Delete trailing white space, useful for Python ;)
func! DeleteTrailingWS()
exe "normal mz"
%s/\s\+$//ge
exe "normal `z"
endfunc
autocmd BufWrite *.py :call DeleteTrailingWS()
set guitablabel=%t
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Cope
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Do :help cope if you are unsure what cope is. It's super useful!
" 快捷键cc表示覆盖当前行
map <leader>cc :botright cope<cr>
map <leader>n :cn<cr>
map <leader>p :cp<cr>
""""""""""""""""""""""""""""""
" => bufExplorer plugin
""""""""""""""""""""""""""""""
let g:bufExplorerDefaultHelp=0
let g:bufExplorerShowRelativePath=1
let g:bufExplorerSortBy = "name"
" map <leader>o :BufExplorer<cr>
""""""""""""""""""""""""""""""
" => Minibuffer plugin
""""""""""""""""""""""""""""""
"let g:miniBufExplModSelTarget = 1
"let g:miniBufExplorerMoreThanOne = 100
"let g:miniBufExplModSelTarget = 0
"let g:miniBufExplUseSingleClick = 1
"let g:miniBufExplMapWindowNavVim = 1
"let g:miniBufExplVSplit = 25
"let g:miniBufExplSplitBelow=1
" 如果需要自动打开,请去掉下面的注释
"autocmd BufRead,BufNew :call UMiniBufExplorer
"map <leader>u :TMiniBufExplorer<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Omni plugin complete functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType c set omnifunc=ccomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
set dictionary-=~/.vim/doc/phpfunclist.txt dictionary+=~/.vim/doc/phpfunclist.txt
set complete-=k complete+=k
let g:SuperTabRetainCompletionType = 1
let g:SuperTabDefaultCompletionType = "<C-N>"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Taglist plugin
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let Tlist_Auto_Highlight_Tag = 1
if !exists( 'Tlist_Auto_Open')
let Tlist_Auto_Open = 0
endif
let Tlist_Auto_Update = 1
let Tlist_Close_On_Select = 0
let Tlist_Compact_Format = 0
let Tlist_Display_Prototype = 0
let Tlist_Display_Tag_Scope = 1
let Tlist_Enable_Fold_Column = 0
let Tlist_Exit_OnlyWindow = 1
let Tlist_File_Fold_Auto_Close = 0
let Tlist_GainFocus_On_ToggleOpen = 1
let Tlist_Hightlight_Tag_On_BufEnter = 1
let Tlist_Inc_Winwidth = 0
let Tlist_Max_Submenu_Items = 1
let Tlist_Max_Tag_Length = 30
let Tlist_Process_File_Always = 0
let Tlist_Show_Menu = 1
let Tlist_Show_One_File = 1
let Tlist_Sort_Type = "name"
let Tlist_Use_Horiz_Window = 0
let Tlist_Use_Right_Window = 1
let Tlist_WinWidth = 30
let Tlist_WinHeight = 40
let Tlist_Ctags_CMD="ctags"
noremap <silent><F6> Tlist<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Spell checking
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Pressing ,ss will toggle and untoggle spell checking
map <leader>ss :setlocal spell!<cr>
"Shortcuts using <leader>
map <leader>sn ]s
map <leader>sp [s
map <leader>sa zg
map <leader>s? z=
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"C语言编译
"设置编译映射为",c"就是在正常模式下输入‘,c'便可编译程序
"设置运行映射为’,r‘就是在正常模式下输入’,r‘便可运行已编译好的程序
"设置编译并运行的映射为’,a‘
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" nmap <leader>c :call CompileC()<CR>
" map <leader>a :call CompileRunC()<CR>
" map <leader>r :call RunC()<CR>
function CompileC()
exec "w"
set makeprg=gcc\ -Wall\ %:p\ -o\ %:r "
exec "make"
exec "copen"
endfunction
"function RunC()
" let s:path=exec "pwd"
" exec "!./%<"
"endfunction
"function CompileRunC()
"exec "w"
"exec "!clear"
"exec "!gcc % -o -%:r"
"exec "!./-%<"
"endfunction
"单个文件编译
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 MySys() == "windows"
set makeprg=gcc\ -o\ %<.exe\ %
else
set makeprg=gcc\ -o\ %<\ %
endif
elseif &filetype=="cpp"
if MySys() == "windows"
set makeprg=g++\ -o\ %<.exe\ %
else
set makeprg=g++\ -o\ %<\ %
endif
"elseif &filetype=="cs"
"set makeprg=csc\ \/nologo\ \/out:%<.exe\ %
endif
if(MySys() == "windows")
let outfilename=substitute(sourcefileename,'\(\.[^.]*\)' ,'.exe','g')
let toexename=outfilename
else
let outfilename=substitute(sourcefileename,'\(\.[^.]*\)' ,'','g')
let toexename=outfilename
endif
if filereadable(outfilename)
if(MySys() == "windows")
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(MySys() == "windows")
execute "!".toexename
else
execute "!./".toexename
endif
else
execute "copen"
redraw!
endif
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
""""""""""""""""""""""""""""""
" => Python section
""""""""""""""""""""""""""""""
let python_highlight_all = 1
au FileType python syn keyword pythonDecorator True None False self
au BufNewFile,BufRead *.jinja set syntax=htmljinja
au BufNewFile,BufRead *.mako set ft=mako
au FileType python inoremap <buffer> $r return
au FileType python inoremap <buffer> $i import
au FileType python inoremap <buffer> $p print
au FileType python inoremap <buffer> $f #--- PH ----------------------------------------------<esc>FP2xi
au FileType python map <buffer> <leader>1 /class
au FileType python map <buffer> <leader>2 /def
au FileType python map <buffer> <leader>C ?class
au FileType python map <buffer> <leader>D ?def
""""""""""""""""""""""""""""""
" => JavaScript section
"""""""""""""""""""""""""""""""
au FileType javascript call JavaScriptFold()
au FileType javascript setl fen
au FileType javascript setl nocindent
au FileType javascript imap <c-t> AJS.log();<esc>hi
au FileType javascript imap <c-a> alert();<esc>hi
au FileType javascript inoremap <buffer> $r return
au FileType javascript inoremap <buffer> $f //--- PH ----------------------------------------------<esc>FP2xi
function! JavaScriptFold()
setl foldmethod=syntax
setl foldlevelstart=1
syn region foldBraces start=/{/ end=/}/ transparent fold keepend extend
function! FoldText()
return substitute(getline(v:foldstart), '{.*', '{...}', '')
endfunction
setl foldtext=FoldText()
endfunction
""""""""""""""""""""""""""""""
" => MRU plugin
""""""""""""""""""""""""""""""
let MRU_Exclude_Files = '^/tmp/.*\|^/var/tmp/.*' " For Unix
"let MRU_Exclude_Files = '^c:\\temp\\.*' " For MS-Windows
let MRU_File = expand('~/.vim/tempfiledir/vim_mru_files')
let MRU_Max_Entries = 100
map <leader>f :MRU<CR>
""""""""""""""""""""""""""""""
" => winManaged plugin
""""""""""""""""""""""""""""""
let g:winManagerWindowLayout = "FileExplorer|TagList|BufExplorer"
let g:winManagerWidth = 30
nmap <silent> <F6> :WMToggle<CR>
""""""""""""""""""""""""""""""
" => NerdTree plugin
""""""""""""""""""""""""""""""
map <leader>fo :NERDTreeToggle<CR>
"nnoremap f :NERDTreeToggle<CR>
""""""""""""""""""""""""""""""
" => Other plugin
" 其他插件设置
""""""""""""""""""""""""""""""
let g:yankring_history_dir = '~/.vim/tempfiledir'
""""""""""""""""""""""""""""""
" => Command-T
""""""""""""""""""""""""""""""
let g:CommandTMaxHeight = 15
set wildignore+=*.o,*.obj,.git,*.pyc
" noremap <leader>j :CommandT<cr>
noremap <leader>y :CommandTFlush<cr>
""""""""""""""""""""""""""""""
" => Vim grep
""""""""""""""""""""""""""""""
let Grep_Skip_Dirs = 'RCS CVS SCCS .svn .git generated'
set grepprg=/bin/grep\ -nH
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => MISC
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remove the Windows ^M - when the encodings gets messed up
noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
"Quickly open a buffer for scripbble
map <leader>q :e ~/buffer<cr>
au BufRead,BufNewFile ~/buffer iab <buffer> xh1 ===========================================
map <leader>pp :setlocal paste!<cr>
map <leader>bb :cd ..<cr>