-
Notifications
You must be signed in to change notification settings - Fork 5
/
vimrc-windows
executable file
·815 lines (669 loc) · 23.1 KB
/
vimrc-windows
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
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
" Author: Felix Yuan
" Email: [email protected]
" Last Modified Date: Jul 5, 2015
" Source: https://github.com/yyscamper/vimconfig
"
" Reference:
" (1) http://amix.dk/vim/vimrc.html
" (2) https://github.com/amix/vimrc
" (3) https://github.com/wklken/k-vim
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Get Global Variables
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if(has("win32") || has("win64") || has("win95") || has("win16"))
let g:iswindows = 1
else
let g:iswindows = 0
endif
if has("gui_running")
let g:isGUI = 1
else
let g:isGUI = 0
endif
if (g:iswindows == 1)
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let eq = ''
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
let cmd = '""' . $VIMRUNTIME . '\diff"'
let eq = '"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Vundle Setting
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible
filetype off
" set the runtime path to include Vundle and initialize
if (g:iswindows == 1)
set rtp+=$VIM/vimfiles/bundle/Vundle.vim/
let path='$VIM/vimfiles/bundle'
call vundle#begin(path)
else
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
endif
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
" Color scheme
Plugin 'altercation/vim-colors-solarized'
" General plugins
"Plugin 'Lokaltog/powerline'
"Plugin 'ashwin/vim-powerline'
Plugin 'bling/vim-airline'
Plugin 'scrooloose/nerdtree'
Plugin 'jistr/vim-nerdtree-tabs'
"Plugin 'bufexplorer.zip'
Plugin 'jeetsukumaran/vim-buffergator'
"Plugin 'rking/ag.vim'
Plugin 'dyng/ctrlsf.vim'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'kshenoy/vim-signature'
Plugin 'ntpeters/vim-better-whitespace'
Plugin 'terryma/vim-expand-region'
Plugin 'easymotion/vim-easymotion'
Plugin 'matze/vim-move'
Plugin 'wincent/command-t'
" Common plugins for source codes
Plugin 'scrooloose/syntastic'
Plugin 'Chiel92/vim-autoformat'
Plugin 'Valloric/YouCompleteMe'
Plugin 'tComment'
Plugin 'Yggdroot/indentLine'
"Plugin 'nathanaelkane/vim-indent-guides'
Plugin 'junegunn/vim-easy-align'
"Plugin 'tpope/vim-surround'
"Plugin 'tpope/vim-repeat'
Plugin 'majutsushi/tagbar'
Plugin 'thinca/vim-quickrun'
Plugin 'kien/rainbow_parentheses.vim'
" Javascript/Node.js
Plugin 'moll/vim-node'
"Plugin 'walm/jshint.vim'
Plugin 'marijnh/tern_for_vim'
Plugin 'pangloss/vim-javascript'
Plugin 'jiangmiao/simple-javascript-indenter'
Plugin 'ramitos/jsctags'
" Python
Plugin 'klen/python-mode'
" JSON
Plugin 'elzr/vim-json'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sets how many lines of history VIM has to remember
set history=700
" Enable filetype plugins
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
let mapleader = ","
let g:mapleader = ","
" Fast saving
nmap <leader>w :w!<cr>
" Quickly close the current window
nnoremap <leader>q :q<CR>
" Map F12 to toggle Paste mode
set pastetoggle=<F12>
" Disbale paste mode when leaving insert mode
au InsertLeave * set nopaste
" Map ; to : to quickly enter command line, this will save a million keystrokes
nnoremap ; :
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM user interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn on the WiLd menu
set wildmenu
" Ignore compiled files
set wildignore=*.o,*~,*.pyc,*.swp,*.bak,*.class,*.svn,*.git
" Make vim do normal (bash like) tab completion
set wildmode=longest:list,full
" Ignore case when searching
set ignorecase
" When searching try to be smart about cases
set smartcase
" Highlight search results
set hlsearch
" Search instantly, makes search act like search in modern browsers
set incsearch
" Don't redraw while executing macros (good performance config)
set lazyredraw
" For regular expressions turn magic on
set magic
" No annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
" Show matching brackets when text indicator is over them
set showmatch
" How many tenths of a second to blink when matching brackets
set mat=2
" Configure backspace so it acts as it should act
"set backspace=eol,start,indent
"set whichwrap+=<,>,h,l
" Set how many lines will be kept visible when move cursor up and down
set scrolloff=7
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use spaces instead of tabs
set expandtab
" Be smart when using tabs
" Insert tabs on the start of a line according to shiftwidth
" Press backspace once will remove 4 spaces
set smarttab
" 1 tab == 4 spaces
set tabstop=4
set softtabstop=4
set shiftwidth=4
" Auto indent, same with set autoindent
set ai "Auto indent
" Smart indent, same with set smartindent
set si "Smart indent
" Don't wrap lines
set nowrap
" Default show line number
set number
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => File encoding
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Try following encoding in following defined order in auto mode
set fileencodings=utf-8,chinese,gbk,utf-16,big5,latin-1
if (g:iswindows == 1)
set fileencoding=chinese
else
set fileencoding=utf-8
endif
" Set new file's encoding
set encoding=utf-8
let &termencoding=&encoding
" Use Unix as the standard file type
set ffs=unix,dos,mac
if (g:isGUI)
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
language messages zh_CN.utf-8
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Backup file to another location, currently disable this
"set backup
"set backext=.bak
"set backupdir=/tmp/vimbackup/
" Turn backup off, since most stuff is in SVN, git et.c anyway...
set nobackup
set nowb
set noswapfile
" Create undo file
if has('persistent_undo')
set undolevels=1000 " How many undos
set undoreload=10000 " number of lines to save for undo
set undofile " So is persistent undo ...
set undodir=/tmp/vimundo/
endif
" Automatically reload the vim configure file if has modification
"autocmd! bufwritepost _vimrc source % " windows
autocmd! bufwritepost .vimrc source % " linux
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
syntax on
" Enable syntax highlighting
syntax enable
set background=dark
colorscheme solarized
let g:solarized_termtrans=0
let g:solarized_degrade=0
let g:solarized_termcolors=256
let g:solarized_contrast="normal"
let g:solarized_visibility="normal"
set t_Co=256
"highlight Normal ctermfg=grey ctermbg=base03
set guifont=Powerline_Consolas:h10
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Visual mode related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Visual mode pressing * or # searches for the current selection
" Super useful! From an idea by Michael Naumann
vnoremap <silent> * :call VisualSelection('f')<CR>
vnoremap <silent> # :call VisualSelection('b')<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Moving around, tabs, windows and buffers
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Useful mappings for managing tabs
map <leader>tt :tabnew<cr>
map <leader>to :tabonly<cr>
map <leader>tq :tabclose<cr>
map <leader>tm :tabmove
map <leader>tp :tabp<cr>
map <leader>tn :tabn<cr>
" Quickly switch to the specified tab
noremap <leader>1 1gt
noremap <leader>2 2gt
noremap <leader>3 3gt
noremap <leader>4 4gt
noremap <leader>5 5gt
noremap <leader>6 6gt
noremap <leader>7 7gt
noremap <leader>8 8gt
noremap <leader>9 9gt
noremap <leader>0 :tablast<cr>
" Opens a new tab with the current buffer's path
" Super useful when editing files in the same directory
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
" Quickly open a buffer for scripbble
map <leader>bb :e ~/buffer<cr>
" Specify the behavior when switching between buffers
try
set switchbuf=useopen,usetab,newtab
set stal=2
catch
endtry
" Return to last edit position when opening files (You want this!)
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" Remember info about open buffers on close
set viminfo^=%
" useful mappings for managing windows
map <leader>wh :wincmd h<cr>
map <leader>wj :wincmd j<cr>
map <leader>wk :wincmd k<cr>
map <leader>wl :wincmd l<cr>
map <leader>wq :wincmd q<cr>
map <leader>ww :wincmd w<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Status line
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Always show the status line
set laststatus=2
" Format the status line
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Editing mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Select whole line
map Y y$
" Select block
nnoremap <leader>v V`}
" Press w!! to sudo & write a file
cmap w!! w !sudo tee >/dev/null %
" Press U for easier redo
nnoremap U <C-r>
" Remove highlight
noremap <silent><leader>/ :nohls<CR>
"Keep search pattern at the center of the screen."
nnoremap <silent> n nzz
nnoremap <silent> N Nzz
nnoremap <silent> * *zz
nnoremap <silent> # #zz
nnoremap <silent> g* g*zz
" Move a line of text
nmap <leader>lj mz:m+<cr>`z
nmap <leader>lk mz:m-2<cr>`z
vmap <leader>lj :m'>+<cr>`<my`>mzgv`yo`z
vmap <leader>lk :m'<-2<cr>`>my`<mzgv`yo`z
" The opened content will still keep in screen after close vim
" This doesn't work well in SSH console
"set t_ti= t_te=
" Delete trailing white space on save
" autocmd BufWrite *.py :call DeleteTrailingWS()
" autocmd BufWrite *.c :call DeleteTrailingWS()
" autocmd BufWrite *.cpp :call DeleteTrailingWS()
" autocmd BufWrite *.js :call DeleteTrailingWS()
" autocmd BufWrite *.java :call DeleteTrailingWS()
" autocmd BufWrite *.xml :call DeleteTrailingWS()
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin: vim-multiple-cursors
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Automatically add the file header for the new file
autocmd BufNewFile *.sh,*.py exec ":call AutoSetFileHead()"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Misc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remove the Windows ^M - when the encodings gets messed up
noremap <Leader>~m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
" Format JSON by json.tool
"nmap <C-J> :%!python -m json.tool<CR>:setfiletype json<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin: NERDTree
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <leader>n :NERDTreeToggle<CR>
let NERDTreeHighlightCursorline=1
let NERDTreeIgnore=[ '\.pyc$', '\.pyo$', '\.obj$', '\.o$', '\.so$', '\.egg$', '^\.git$', '^\.svn$', '^\.hg$' ]
"close vim if the only window left open is a NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | end
" s/v to open file in different screen
let g:NERDTreeMapOpenSplit = 's'
let g:NERDTreeMapOpenVSplit = 'v'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin: NERDTree-tab
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <Leader>n <plug>NERDTreeTabsToggle<CR>
map <F5> <plug>NERDTreeTabsToggle<CR>
let g:nerdtree_tabs_synchronize_view=0
let g:nerdtree_tabs_synchronize_focus=0
"let g:nerdtree_tabs_open_on_console_startup=1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin: command-t
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"nnoremap <silent> <Leader>t :CommandT<CR>
map <C-t> :CommandT<CR>
let g:CommandTSmartCase = 1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin: buffergator
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" New Buffergator window will be opened in horizontal top
" "L" : vertical left (full screen height)
" "R" : vertical right (full screen height)
" "T" : horizontal top (full screen width)
" "B" : horizontal bottom (full screen width)
let g:buffergator_viewport_split_policy = "T"
" Don't use default key mapping
let g:buffergator_suppress_keymaps = 0
let g:buffergator_suppress_mru_switch_into_splits_keymaps = 0
nnoremap <silent> <Leader>b :BuffergatorOpen<CR>
nnoremap <silent> <Leader>B :BuffergatorClose<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin: ag.vim
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Search by press :Ag [options] {pattern} [{directory}]
" let g:agprg = 'ag --smart-case --skip-vcs-ignores --nogroup --nocolor --column'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin: ctrlsf.vim
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nmap \ <Plug>CtrlSFCwordPath<CR>
map <C-f> <Esc><Plug>CtrlSFPrompt
imap <leader>fv <Esc>:CtrlSFToggle<CR>
nmap <leader>fv :CtrlSFToggle<CR>
" let g:ctrlsf_position = 'below'
" let g:ctrlsf_winsize = '30%'
let g:ctrlsf_auto_close = 0
let g:ctrlsf_confirm_save = 0
let g:ctrlsf_default_root = 'cwd'
let g:ctrlsf_context = '-B 2 -A 2'
" Note: cannot use <CR> or <C-m> for open
" Use : <sapce> or <tab>
let g:ctrlsf_mapping = {
\ "open" : "<Space>",
\ "openb" : "O",
\ "tab" : "t",
\ "tabb" : "T",
\ "prevw" : "p",
\ "quit" : "q",
\ "next" : "n",
\ "prev" : "N",
\ "pquit" : "q",
\ }
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin: vim-signature
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Toggle the visible of mark and marker
nnoremap <silent> <Leader>mv :SignatureToggleSigns<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin: vim-move
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:move_key_modifier = 'C'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin: vim-multiple-cursors
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Don't use plugin's default key mapping
let g:multi_cursor_use_default_mapping=0
let g:multi_cursor_next_key='<C-m>'
let g:multi_cursor_prev_key='<C-p>'
let g:multi_cursor_skip_key='<C-x>'
let g:multi_cursor_quit_key='<Esc>'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin: vim-better-whitespace
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nmap <leader><space>d :StripWhitespace<CR>
"nmap <leader><space>t :ToggleWhitespace<CR>
autocmd FileType javascript,python,c,cpp,java,html,xml,json autocmd BufWritePre <buffer> StripWhitespace
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin: powerline
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set t_Co=256
set laststatus=2
let g:Powerline_symbols = 'fancy'
set fillchars+=stl:\ ,stlnc:\
let g:airline_powerline_fonts = 1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin: YouCompleteMe
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:ycm_complete_in_comments=1
let g:ycm_confirm_extra_conf=0
let g:ycm_collect_identifiers_from_tags_files=1
inoremap <leader>; <C-x><C-o>
set completeopt-=preview
let g:ycm_min_num_of_chars_for_completion=1
let g:ycm_cache_omnifunc=0
let g:ycm_seed_identifiers_with_syntax=1
let g:ycm_key_invoke_completion = '<M-;>'
nmap <M-g> :YcmCompleter GoToDefinitionElseDeclaration <C-R>=expand("<cword>")<CR><CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin: vim-json
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:vim_json_syntax_conceal = 0
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin: vim-autoformat
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nmap <C-y> :Autoformat<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin: vim indent line
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vim
let g:indentLine_color_term = 0
"GVim
let g:indentLine_color_gui = '#1c1c1c'
" none X terminal
let g:indentLine_color_tty_light = 7 " (default: 4)
let g:indentLine_color_dark = 1 " (default: 2)
" change the ident char
let g:indentLine_char = '|'
" disable by default
"let g:indentLine_enabled = 0
" Toggle both indent line and the line number, so it is useful when you
" want to copy the screen output
:noremap <F11> :IndentLinesToggle<CR>:set number!<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin: tComment
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Comment one line
:map <C-L> gc
:nmap <leader>cl gc
" Comment block, only useful on visual mode
:vmap <C-B> <C-_>b
vmap <leader>cb <C-_>b
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin: vim easy align
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Start interactive EasyAlign in visual mode (e.g. vip<Enter>)
vmap <Leader>al <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
"nmap <Leader>al <Plug>(EasyAlign)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin: tagbar
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"if jsctags is not in the $PATH, you need to add following
let g:tagbar_type_javascript = {
\ 'ctagsbin' : '/home/onrack/npm/lib/node_modules/jsctags/bin/jsctags'
\ }
" Map F2 to toggle the tag bar
nmap <F2> :TagbarToggle<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin: Syntastic
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:syntastic_python_checkers = ['pylint']
"set statusline+=%#warningmsg#
"set statusline+=%{SyntasticStatuslineFlag()}
"set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 0
let g:syntastic_check_on_wq = 0
" Manually do syntastic check
noremap <F3> :SyntasticCheck<CR>:Errors<CR>
" Close the error list
noremap <F4> ::SyntasticReset<CR>
noremap <leader>sn :lnext<CR>
noremap <leader>sp :lprevious<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin: python-mode
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:pymode = 0
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin: quickrun
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:quickrun_config = {
\ "_" : {
\ "outputter" : "message",
\ },
\}
let g:quickrun_no_default_key_mappings = 1
nmap <Leader>r <Plug>(quickrun)
map <F10> :QuickRun<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin: Rainbow Parentheses
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:rbpt_colorpairs = [
\ ['brown', 'RoyalBlue3'],
\ ['Darkblue', 'SeaGreen3'],
\ ['darkgray', 'DarkOrchid3'],
\ ['darkgreen', 'firebrick3'],
\ ['darkcyan', 'RoyalBlue3'],
\ ['darkred', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['brown', 'firebrick3'],
\ ['gray', 'RoyalBlue3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['Darkblue', 'firebrick3'],
\ ['darkgreen', 'RoyalBlue3'],
\ ['darkcyan', 'SeaGreen3'],
\ ['darkred', 'DarkOrchid3'],
\ ['red', 'firebrick3'],
\ ]
let g:rbpt_max = 16
let g:rbpt_loadcmd_toggle = 0
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin: vim-expand-region
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
vmap v <Plug>(expand_region_expand)
vmap V <Plug>(expand_region_shrink)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin: vim-easy-motion
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:EasyMotion_smartcase = 1
"let g:EasyMotion_startofline = 0 " keep cursor colum when JK motion
map <Leader><leader>h <Plug>(easymotion-linebackward)
map <Leader><Leader>j <Plug>(easymotion-j)
map <Leader><Leader>k <Plug>(easymotion-k)
map <Leader><leader>l <Plug>(easymotion-lineforward)
"map <Leader><leader>. <Plug>(easymotion-repeat)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Helper functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! CmdLine(str)
exe "menu Foo.Bar :" . a:str
emenu Foo.Bar
unmenu Foo
endfunction
function! VisualSelection(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 == 'replace'
call CmdLine("%s" . '/'. l:pattern . '/')
elseif a:direction == 'f'
execute "normal /" . l:pattern . "^M"
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
" Returns true if paste mode is enabled
function! HasPaste()
if &paste
return 'PASTE MODE '
en
return ''
endfunction
" 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
" automatically set the header of the new file
function! AutoSetFileHead()
" .sh
if &filetype == 'sh'
call setline(1, "\#!/bin/bash")
endif
" python
if &filetype == 'python'
call setline(1, "\#!/usr/bin/env python")
" call append(1, "\# encoding: utf-8")
endif
" javascript (node.js)
" if &filetype == 'javascript'
" call setline(1, "\#!/usr/bin/env node")
" endif
normal G
normal o
normal o
endfunc
" Delete trailing white space on save, useful for Python and CoffeeScript ;)
func! DeleteTrailingWS()
exe "normal mz"
%s/\s\+$//ge
exe "normal `z"
endfunc