-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvimrc
More file actions
679 lines (588 loc) · 19.6 KB
/
Copy pathvimrc
File metadata and controls
679 lines (588 loc) · 19.6 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
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
"behave mswin"{{{
" Sections:
" -> General
" -> VIM user interface
" -> Colors and Fonts
" -> Files and backups
" -> Text, tab and indent related
" -> Visual mode related
" -> Command mode related
" -> Moving around, tabs and buffers
" -> Statusline
" -> Parenthesis/bracket expanding
" -> General Abbrevs
" -> Editing mappings
"
" -> Cope
" -> Minibuffer plugin
" -> Omni complete functions
" -> Folding
" -> snipMate
" -> WinManager
" -> vim cycle
" -> cscope setting
" -> latex
" -> DoxygenToolkit
" -> some map
" -> tmux fixes
" -> jedi-vim
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""}}}
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible
"set spell
"set spellfile=~/vim/spell.utf8.add
set sessionoptions-=curdir
set sessionoptions+=sesdir,slash,unix
set viminfo='100,<50,s10,h
" Sets how many lines of history VIM has to remember
set history=700
" pathogen.vim
call pathogen#infect()
" Enable filetype plugin
filetype plugin on
filetype indent on
" Set to auto read when a file is changed from the outside
set autoread
augroup checktime
au!
if !has("gui_running")
"silent! necessary otherwise throws errors when using command
"line window.
autocmd BufEnter * silent! checktime
autocmd CursorHold * silent! checktime
autocmd CursorHoldI * silent! checktime
"these two _may_ slow things down. Remove if they do.
"autocmd CursorMoved * silent! checktime
"autocmd CursorMovedI * silent! checktime
endif
augroup END
" 自动命令
" 读文件时自动设定当前目录为刚读入文件所在的目录
autocmd BufReadPost * cd %:p:h
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let mapleader = ","
let g:mapleader = ","
" Fast saving
nmap <leader>w :w!<cr>
" Fast editing of the .vimrc
map <leader>e :e! ~/vim/vimrc<cr>
" When vimrc is edited, reload it
autocmd! bufwritepost vimrc source ~/vim/vimrc
"au BufRead,BufNewFile *.c,*.cpp,*.py match Error /\%80v.\%80v./
"au BufRead,BufNewFile *.c,*.cpp,*.py 2match Underlined /.\%81v/
"This is for setting Makefiles with tabs not spaces
autocmd FileType make setlocal noexpandtab
if MySys() == "windows"
set clipboard=unnamed
elseif MySys() == "linux"
set clipboard=unnamedplus
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM user interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" VIM user interface {{{1
" Set 7 lines to the curors - when moving vertical..
set so=7
set wildmenu "Turn on WiLd menu
set nu
set ruler "Always show current position
set cmdheight=2 "The commandbar height
"set hid "Change buffer - without saving
" Set backspace config
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
set ignorecase "Ignore case when searching
set smartcase
set hlsearch "Highlight search things
set incsearch "Make search act like search in modern browsers
set nolazyredraw "Don't redraw while executing macros
"set cursorline " Highlight current line
"set cursorcolumn " Highlight current column
set magic "Set magic on, for regular expressions
set showmatch "Show matching bracets when text indicator is over them
set mat=2 "How many tenths of a second to blink
" No sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
"}}}
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Colors and Fonts {{{1
syntax enable "Enable syntax hl
" Set font according to system
if MySys() == "mac"
set gfn=Menlo:h14
set shell=/bin/bash
elseif MySys() == "windows"
set guifont=Courier_New:h12:cANSI
"set guifontwide=Microsoft_YaHei_Mono:h12:cGB2312
"set gfn=Bitstream\ Vera\ Sans\ Mono:h10
elseif MySys() == "linux"
set gfn=Monospace\ 12
set shell=/bin/bash
endif
if has("gui_running")
set guioptions-=T
set t_Co=256
set background=dark
"colorscheme peaksea
"colorscheme freya
"colorscheme mydesert
colorscheme solarized
"colorscheme desert
else
"let g:solarized_termcolors=256
let g:solarized_termtrans=1
"colorscheme desert
colorscheme solarized
"colorscheme zellner
set background=dark
"set nonu
endif
"set encoding=utf8
"try
" lang en_US
"catch
"endtry
set encoding=utf-8
set fileencodings=ucs-bom,utf-8,gb18030,big5,euc-jp,euc-kr,ucs-2le,latin1
"set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,ucs-2le,latin1
set termencoding=utf-8
set fileencoding=utf-8
"set ffs=dos,unix,mac "Default file types
"}}}
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Files, backups and undo {{{1
" Turn backup off, since most stuff is in SVN, git anyway...
set nobackup
set nowritebackup
set noswapfile
"Persistent undo
"try
" if MySys() == "windows"
" set undodir=C:\Windows\Temp
" else
" set undodir=~/.vim_runtime/undodir
" endif
"
" set undofile
"catch
"endtry
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set expandtab " 将 tab 键转换为空格
set shiftwidth=4
set tabstop=4
set smarttab
set lbr " linebreak
set tw=500 fo+=Mm
set ai "Auto indent
set si "Smart indet
set wrap "Wrap lines
"}}}
"""""""""""""""""""""""""""""""
"" => Visual mode related
"""""""""""""""""""""""""""""""
"" Visual mode related {{{1
"" 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
"}}}
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Moving around, tabs and buffers
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Moving around, tabs and buffers {{{1
" 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-J> conflict with imaps(used by latex), so change imaps to <C-J>
"map <C-k> <C-W>k
"map <C-h> <C-W>h
"map <C-l> <C-W>l
"map <C-j> <C-W>j
" Close the current buffer
map <leader>bd :Bclose<cr>
" 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
""""""""""""""""""""""""""""""
" Statusline {{{1
" Always hide the statusline
set laststatus=2 " 显示状态栏 (默认值为 1, 无法显示状态栏)
" Format the statusline
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ %r%{&fileformat}%h\ \ \ Line:\ %l/%L:%c
"set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c
function! CurDir()
if MySys() == "windows"
let curdir = substitute(getcwd(), 'c:\\Users\\Tech2\\', "~/", "g")
elseif MySys() == "linux"
let curdir = substitute(getcwd(), '/home/iceout/', "~/", "g")
endif
return curdir
endfunction
function! HasPaste()
if &paste
return 'PASTE MODE '
else
return ''
endif
endfunction
""set statusline=%F%m%r,%Y,%{&fileformat}\ \ ASCII=\%b,HEX=\%B\ \ %l,%c\ %p%%\ \ [\ %L\ lines\ in\ all\ ]
" 设置在状态行显示的信息如下:
" %F 当前文件名
" %m 当前文件修改状态
" %r 当前文件是否只读
" %Y 当前文件类型
" %{&fileformat}
" 当前文件编码
" %b 当前光标处字符的 ASCII 码值
" %B 当前光标处字符的十六进制值
" %l 当前光标行号
" %c 当前光标列号
" %V 当前光标虚拟列号 (根据字符所占字节数计算)
" %p 当前行占总行数的百分比
" %% 百分号
" %L 当前文件总行数
"}}}
""""""""""""""""""""""""""""""
" => minibufExplorer plugin
""""""""""""""""""""""""""""""
" bufExplorer plugin {{{1
let g:bufExplorerDefaultHelp=0
let g:miniBufExplorerMoreThanOne=0
let g:bufExplorerShowRelativePath=1
map <leader>o :BufExplorer<cr>
"}}}
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Omni complete functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Omni{{{1
set completeopt=menu,menuone
let OmniCpp_SelectFirstItem = 2
set ofu=syntaxcomplete#Complete
"autocmd FileType python set omnifunc=pythoncomplete#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 java set omnifunc=javacomplete#Complet
"let OmniCpp_NamespaceSearch = 1
"let OmniCpp_GlobalScopeSearch = 1
"let OmniCpp_ShowAccess = 1
"let OmniCpp_ShowPrototypeInAbbr = 1 " show function parameters
"let OmniCpp_MayCompleteDot = 1 " autocomplete after .
"let OmniCpp_MayCompleteArrow = 1 " autocomplete after ->
"let OmniCpp_MayCompleteScope = 1 " autocomplete after ::
"let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
"}}}
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Folding
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Folding {{{1
"折叠相关的快捷键
"zR 打开所有的折叠
"za Open/Close (toggle) a folded group of lines.
"zA Open a Closed fold or close and open fold recursively.
"zi 全部 展开/关闭 折叠
"zo 打开 (open) 在光标下的折叠
"zc 关闭 (close) 在光标下的折叠
"zC 循环关闭 (Close) 在光标下的所有折叠
"zM 关闭所有可折叠区域
set foldenable
" 设置语法折叠
" manual 手工定义折叠
" indent 更多的缩进表示更高级别的折叠
" expr 用表达式来定义折叠
" syntax 用语法高亮来定义折叠
" diff 对没有更改的文本进行折叠
" marker 对文中的标志折叠
set foldmethod=indent
" 设置折叠层数为
set foldlevel=99
" 设置折叠区域的宽度
"set foldcolumn=0
" 新建的文件,刚打开的文件不折叠
"autocmd! BufNewFile,BufRead * setlocal nofoldenable
" }}}
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => snipMate
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" snipMate {{{1
let g:snips_author='iceout'
let g:snips_email='ice.404.out@gmail.com'
let g:snipMate = { 'snippet_version' : 1 }
"}}}
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => WinManager
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"let g:winManagerWindowLayout='FileExplorer|TagList'
"let g:winManagerWindowLayout='NERDTree|TagList,BufExplorer'
let g:winManagerWindowLayout='NERDTree'
nmap wm :WMToggle<cr>:q<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Uncomment the following to have Vim jump to the
" last position when reopening a file
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => vim cycle
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"{{{1
let g:cycle_default_groups = [
\ [['true', 'false']],
\ [['yes', 'no']],
\ [['on', 'off']],
\ [['+', '-']],
\ [['>', '<']],
\ [['"', "'"]],
\ [['==', '!=']],
\ [['0', '1']],
\ [['and', 'or']],
\ [["in", "out"]],
\ [["up", "down"]],
\ [["min", "max"]],
\ [["get", "set"]],
\ [["add", "remove"]],
\ [["to", "from"]],
\ [["read", "write"]],
\ [["only", "except"]],
\ [['without', 'with']],
\ [["exclude", "include"]],
\ [["asc", "desc"]],
\ [['是', '否']],
\ [['{:}', '[:]', '(:)'], 'sub_pairs'],
\ [['(:)', '「:」', '『:』'], 'sub_pairs'],
\ [['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday',
\ 'Friday', 'Saturday'], 'hard_case', {'name': 'Days'}],
\ ]
"}}}
au VimEnter * RainbowParenthesesToggle
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" cscope setting
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" cscope {{{1
if has("cscope") && executable("cscope")
" 设置 {{{2
set csto=1
set cst
set cscopequickfix=s-,c-,d-,i-,t-,e-,f-
" add any database in current directory
function! CSadd()
set nocsverb
if filereadable("cscope.out")
cs add cscope.out
endif
set csverb
endfunction
autocmd BufRead *.c,*.cpp,*.h call CSadd()
" 映射 {{{2
" 查找C语言符号,即查找函数名、宏、枚举值等出现的地方
nmap css :cs find s <C-R>=expand("<cword>")<CR><CR>
" 查找函数、宏、枚举等定义的位置,类似ctags所提供的功能
nmap csg :cs find g <C-R>=expand("<cword>")<CR><CR>
" 查找本函数调用的函数
nmap csd :cs find d <C-R>=expand("<cword>")<CR><CR>
" 查找调用本函数的函数
nmap csc :cs find c <C-R>=expand("<cword>")<CR><CR>:cw<CR>
" 查找指定的字符串
nmap cst :cs find t <C-R>=expand("<cword>")<CR><CR>
" 查找egrep模式,相当于egrep功能,但查找速度快多了
nmap cse :cs find e <C-R>=expand("<cword>")<CR><CR>
" 查找并打开文件,类似vim的find功能
nmap csf :cs find f <C-R>=expand("<cfile>")<CR><CR>
" 查找包含本文件的文件
nmap csi :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
" 生成新的数据库
nmap csn :lcd %:p:h<CR>:!my_cscope<CR>
" 自己来输入命令
nmap cs<Space> :cs find
endif
"}}}1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" latex
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" latex {{{1
" REQUIRED. This makes vim invoke Latex-Suite when you open a tex file.
"filetype plugin on
" IMPORTANT: win32 users will need to have 'shellslash' set so that latex
" can be called correctly.
set shellslash
" IMPORTANT: grep will sometimes skip displaying the file name if you
" search in a singe file. This will confuse Latex-Suite. Set your grep
" program to always generate a file-name.
set grepprg=grep\ -nH\ $*
" OPTIONAL: This enables automatic indentation as you type.
"filetype indent on
" OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to
" 'plaintex' instead of 'tex', which results in vim-latex not being loaded.
" The following changes the default filetype back to 'tex':
let g:tex_flavor='latex'
"}}}1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Git Vim configuration
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"git {{{1
"map <buffer> <leader>gs :GitStatus<cr>
"map <buffer> <leader>gc :GitCommit<cr>
"map <buffer> <leader>ga :GitAdd
"map <buffer> <leader>gA :GitAdd <cfile>
"map <buffer> <leader>gp :GitPush
"map <buffer> <leader>gl :GitPull
"}}}1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => DoxygenToolkit
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:DoxygenToolkit_briefTag_pre="@Synopsis "
let g:DoxygenToolkit_paramTag_pre="@Param "
let g:DoxygenToolkit_returnTag="@Returns "
let g:DoxygenToolkit_authorName="iceout"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => some map
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nmap <F4> :cw<cr>
"map <C-F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
nmap <silent> <leader>ec :echo Google_Translate('en','zh-CN',expand('<cword>'))<CR>
set list listchars=tab:>-,trail:·
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => python
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
autocmd BufWritePost *.py call flake8#Flake8()
""""""""""""""
" tmux fixes "
""""""""""""""
" Handle tmux $TERM quirks in vim
if $TERM =~ '^screen-256color'
map <Esc>OH <Home>
map! <Esc>OH <Home>
map <Esc>OF <End>
map! <Esc>OF <End>
endif
""""""""""""""
" jedi-vim"
""""""""""""""
"let g:jedi#use_tabs_not_buffers = 0
"let g:jedi#use_splits_not_buffers = "left"
"let g:jedi#goto_assignments_command = "<leader>g"
"let g:jedi#goto_definitions_command = "<leader>d"
"let g:jedi#documentation_command = "K"
"let g:jedi#usages_command = "<leader>n"
"let g:jedi#completions_command = "<C-Space>"
"let g:jedi#rename_command = "<leader>r"
"let g:jedi#show_call_signatures = "1"
" Format code style
func! FormatSrc()
exec "w"
if &filetype == 'c'
exec "!astyle --style=ansi --one-line=keep-statements -a --suffix=none %"
elseif &filetype == 'cpp' || &filetype == 'hpp'
exec "r !astyle --style=ansi --one-line=keep-statements -a --suffix=none %> /dev/null 2>&1"
elseif &filetype == 'perl'
exec "!astyle --style=gnu --suffix=none %"
elseif &filetype == 'py'||&filetype == 'python'
exec "r !autopep8 -i --aggressive --ignore=W690,E501 %"
elseif &filetype == 'java'
exec "!astyle --style=java --suffix=none %"
elseif &filetype == 'jsp'
exec "!astyle --style=gnu --suffix=none %"
elseif &filetype == 'xml'
exec "!astyle --style=gnu --suffix=none %"
endif
exec "e! %"
endfunc
" autopep8
noremap <silent><Leader>f :call FormatSrc()<CR>
" acp
" 禁用python的补全
let g:acp_behaviorPythonOmniLength = -1
" Allow saving of files as sudo when I forgot to start vim using sudo.
cmap w!! w !sudo tee > /dev/null %
" airline
let g:airline#extensions#tabline#enabled = 1
let g:airline_theme='deus'
" auto set paste & nopaste
let &t_SI .= "\<Esc>[?2004h"
let &t_EI .= "\<Esc>[?2004l"
inoremap <special> <expr> <Esc>[200~ XTermPasteBegin()
function! XTermPasteBegin()
set pastetoggle=<Esc>[201~
set paste
return ""
endfunction