-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
1082 lines (874 loc) · 28 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
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
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Version:
" 18.01 - 08/29/2019
"
" Sections:
" -> Initialize
" -> General
" -> VIM user interface
" -> Colors and Fonts
" -> Files and backups
" -> Text, tab and indent related
" -> Visual mode related
" -> Moving around, tabs and buffers
" -> Status line
" -> Editing mappings
" -> Searching vimgrep
" -> Spell checking
" -> Misc
" -> Helper functions
" -> Filetypes and Completions
" -> LeaderMappings
" -> Useful
" -> ModeMappings
" -> Plugins - normal
" -> Plugins - development
"
augroup Omni
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Initialize
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible
filetype off
" curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
"
call plug#begin()
" Normal -STD
Plug 'itchyny/lightline.vim'
Plug 'jlanzarotta/bufexplorer'
Plug 'justinmk/vim-dirvish'
Plug 'moll/vim-bbye'
Plug 'vim-scripts/matchit.zip'
Plug 'Valloric/MatchTagAlways'
Plug 'alvan/vim-closetag'
Plug 'tomasr/molokai'
Plug 'ErichDonGubler/vim-sublime-monokai'
Plug 'mileszs/ack.vim'
Plug 'tpope/vim-unimpaired'
Plug 'milkypostman/vim-togglelist'
Plug 'kshenoy/vim-signature'
Plug 'Raimondi/delimitMate'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'rhysd/clever-f.vim'
Plug 'tommcdo/vim-lion'
Plug 'junegunn/vim-peekaboo'
Plug 'terryma/vim-expand-region'
Plug 'ledger/vim-ledger'
Plug 'vimoutliner/vimoutliner'
Plug 'mtth/scratch.vim'
Plug 'plasticboy/vim-markdown'
Plug 'lambdalisue/vim-foldround'
Plug 'christoomey/vim-tmux-navigator'
Plug 'benmills/vimux'
Plug 'kana/vim-arpeggio'
Plug 'jamessan/vim-gnupg'
Plug 'svermeulen/vim-cutlass'
Plug 'svermeulen/vim-yoink'
Plug 'svermeulen/vim-subversive'
Plug 'tpope/vim-commentary'
Plug 'lfilho/cosco.vim'
Plug 'kana/vim-textobj-user'
Plug 'kana/vim-textobj-function'
Plug 'jasonlong/vim-textobj-css'
Plug 'kana/vim-textobj-line'
Plug 'haya14busa/vim-textobj-function-syntax'
Plug 'zirrostig/vim-schlepp'
Plug 'mhinz/vim-grepper'
"startabc
if $HSDVIM == 'dev'
" load DEVELOPMENT vimrc
source $HOME/.dotfiles/vim-dev
endif
"endabc
call plug#end()
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable filetype plugins
filetype plugin on
filetype indent on
" syntax highlighting
syntax 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 = ","
nnoremap <Space> <nop>
let mapleader = " "
" Fast saving
nnoremap <leader>w :w!<cr>
" Sets how many lines of history VIM has to remember
set history=500
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM user interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set 7 lines to the cursor - when moving vertically using j/k
set scrolloff=7
set sidescrolloff=8
set sidescroll=1
" Avoid garbled characters in Chinese language windows OS
let $LANG='en'
set langmenu=en
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
" Turn on the WiLd menu
set wildmenu
" set wildmode=list:longest,full
set wildmode=longest:full,full
" Ignore files
set wildignore=*.o,*.obj,*~
set wildignore+=*sass-cache*
set wildignore+=*DS_Store*
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*
set wildignore+=vendor/rails/**
set wildignore+=vendor/cache/**
set wildignore+=*.gem
set wildignore+=log/**
set wildignore+=tmp/**
set wildignore+=*.png,*.jpg,*.gif
set wildignore+=*.so,*.swp,*.zip,*/.Trash/**,*.pdf,*.dmg,*/Library/**,*/.rbenv/**
set wildignore+=*/.nx/**,*.app
set wildignore+=*/node_modules/**,*/bower_components/**
"Always show current position
set ruler
" Height of the command bar
set cmdheight=1
" A buffer becomes hidden when it is abandoned
set hidden
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
"set whichwrap=b,s,h,l,<,>,[,]
" Ignore case when searching
set ignorecase
" When searching try to be smart about cases
set smartcase
" Highlight search results
set hlsearch
" 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
" Show matching brackets when text indicator is over them
set showmatch
" How many tenths of a second to blink when matching brackets
set matchtime=2
" No annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set timeout
set timeoutlen=500 " maybe 500
set ttimeoutlen=100
" Properly disable sound on errors on MacVim
if has("gui_macvim")
autocmd GUIEnter * set vb t_vb=
endif
" Add a bit extra margin to the left
"set foldcolumn=1
set foldcolumn=0
set numberwidth=3
" tmux
if !$TMUX | set t_ut= | endif
" ctags
set tags=./tags;/
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable syntax highlighting
syntax enable
" 256bit terminal
set t_Co=256
set background=dark
try
"colorscheme molokai
colorscheme sublimemonokai
catch
colorscheme desert
endtry
hi Normal ctermbg=none
" using Source Code Pro
" set guifont=Source\ Code\ Pro:h14
" Set extra options when running in GUI mode
if has("gui_running")
set guioptions-=T
set lines=35
set columns=90
set guioptions-=e
set t_Co=256
set guitablabel=%M\ %t
if has("gui")
"set guifont=Inconsolata\ 12
set guifont=Hack\ 14
elseif has("gui_macvim")
set guifont=Menlo\ Regular:h14
elseif has("gui_win32")
"set guifont=Consolas:h11:cANSI
set guifont=Source\ Code\ Pro:h14
endif
endif
" Set utf8 as standard encoding and en_US as the standard language
set encoding=utf8
" Use Unix as the standard file type
set ffs=unix,dos,mac
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git et.c anyway...
set nobackup
set nowritebackup
"set noswapfile
set backupdir=~/.vim/.tmp/backup//
set directory=~/.vim/.tmp/swap//
" set undodir=~/.vim/.tmp/undo//
set swapfile
" set undofile
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use spaces instead of tabs
set expandtab
" Be smart when using tabs ;)
set smarttab
" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4
" Linebreak on 500 characters
set linebreak
set textwidth=500
" use multiple of shiftwidth when indenting with '<' and '>'
set shiftround
set autoindent
set smartindent
" no wrap lines
set nowrap "No Wrap lines
" Keep visual selecting after indenting a block
vnoremap > >gv
vnoremap < <gv
" listchars
set nolist
" Display unprintable chars
"set listchars=tab:»·
"set listchars+=nbsp:.
set listchars=eol:¬
set listchars+=trail:·
set listchars+=tab:▸\ ,extends:❯,precedes:❮,nbsp:␣
""""""""""""""""""""""""""""""
" => Visual mode related
""""""""""""""""""""""""""""""
" Visual mode pressing * or # searches for the current selection
vnoremap <silent> * :<C-u>call VisualSelection('', '')<CR>/<C-R>=@/<CR><CR>
vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Moving around, tabs, windows and buffers
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Disable highlight when <leader><cr> is pressed
nnoremap <silent> <leader><cr> :nohlsearch<cr>
" Smart way to move between windows
nnoremap <C-j> <C-W>j
nnoremap <C-k> <C-W>k
nnoremap <C-h> <C-W>h
nnoremap <C-l> <C-W>l
" Close all the buffers
nnoremap <leader>ba :bufdo bd<cr>
nnoremap <leader>l :bnext<cr>
nnoremap <leader>h :bprevious<cr>
" managing tabs
nnoremap <leader>to :tabonly<cr>
nnoremap <leader>tc :tabclose<cr>
nnoremap <leader>tn :tabnew<Space>
nnoremap <leader>tk :tabnext<CR>
nnoremap <leader>tj :tabprevious<CR>
nnoremap <leader>th :tabfirst<CR>
nnoremap <leader>tl :tablast<CR>
" Let 'tl' toggle between this and the last accessed tab
let g:lasttab = 1
nnoremap <Leader>tp :exe "tabn ".g:lasttab<CR>
au TabLeave * let g:lasttab = tabpagenr()
" Opens a new tab with the current buffer's path
" for editing files in the same directory
nnoremap <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
" Switch CWD to the directory of the open buffer
nnoremap <leader>cd :cd %:p:h<cr>:pwd<cr>
" Specify the behavior when switching between buffers
set switchbuf=useopen,usetab
" Return to last edit position when opening files (You want this!)
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
" Treat long lines as break lines
nnoremap j gj
nnoremap k gk
" disable arrow keys
" nnoremap <up> <nop>
" nnoremap <down> <nop>
" nnoremap <left> <nop>
" nnoremap <right> <nop>
" inoremap <up> <nop>
" inoremap <down> <nop>
" inoremap <left> <nop>
" inoremap <right> <nop>
" Up Down Left Right resize splits
" nnoremap <up> <c-w>+
" nnoremap <down> <c-w>-
" nnoremap <left> <c-w><
" nnoremap <right> <c-w>>
""""""""""""""""""""""""""""""
" => 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\ \ Column:\ %c
" Hide INSERT when using lightline.vim
set noshowmode
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Editing mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remap VIM 0 to first non-blank character
nnoremap 0 ^
" Move a line of text using ALT+[jk]
nnoremap <M-j> mz:m+<cr>`z
nnoremap <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
" Delete trailing white space on save
fun! CleanExtraSpaces()
let save_cursor = getpos(".")
let old_query = getreg('/')
silent! %s/\s\+$//e
call setpos('.', save_cursor)
call setreg('/', old_query)
endfun
augroup infosec01
autocmd!
autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces()
augroup end
nnoremap <leader>ws :call CleanExtraSpaces()<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Searching vimgrep
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Easier (s)earch and (r)eplace
nnoremap <leader>r :%s/<c-r><c-w>//g<left><left>
" Easier search and replace - visual
vnoremap <leader>r "hy:%s/<c-r>h//g<left><left>
" n: Next, keep search matches in the middle of the window
nnoremap n nzzzv
" Search mappings: search will center on the line
map N Nzzv
" fzf search
nnoremap <leader>s :Ag
nnoremap <leader>/ :BLines<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Spell checking
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Pressing ,ss will toggle and untoggle spell checking
nnoremap <leader>ss :setlocal spell!<cr>
" Shortcuts using <leader>
nnoremap <leader>sn ]s
nnoremap <leader>sp [s
nnoremap <leader>sa zg
nnoremap <leader>s? z=
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Misc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remove the Windows ^M - when the encodings gets messed up
noremap <Leader>4 mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
" markdown set conceal level
noremap <Leader>m :set conceallevel=2
" disable mode lines (security measure)
set nomodeline
" definition window
set completeopt-=preview
set completeopt+=menu,menuone,noinsert,noselect
set shortmess+=c
" relative numbers in normal mode and the regular line numbers in insert mode.
set relativenumber
augroup infosec02
autocmd!
autocmd InsertEnter * :set number norelativenumber
autocmd InsertLeave * :set number relativenumber
augroup end
" set initial path
cd %:p:h
" stop EX mode
nnoremap Q <nop>
" my templates
nmap <F4> a<C-R>=strftime("%Y-%m-%d")<CR><Esc>
imap <F4> <C-R>=strftime("%Y-%m-%d")<CR>
nmap <F5> ilogin:<CR>url:<CR><Esc>
imap <F5> login:<CR>url:<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Helper functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Returns true if paste mode is enabled
function! HasPaste()
if &paste
return 'PASTE MODE '
endif
return ''
endfunction
function! CmdLine(str)
exe "menu Foo.Bar :" . a:str
emenu Foo.Bar
unmenu Foo
endfunction
function! VisualSelection(direction, extra_filter) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", "\\/.*'$^~[]")
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'gv'
call CmdLine("Ack '" . l:pattern . "' " )
elseif a:direction == 'replace'
call CmdLine("%s" . '/'. l:pattern . '/')
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
" Return TRUE if in the middle of {} or () in INSERT mode
fun BreakLine()
if (mode() == 'i')
return ((getline(".")[col(".")-2] == '{' && getline(".")[col(".")-1] == '}') ||
\(getline(".")[col(".")-2] == '(' && getline(".")[col(".")-1] == ')'))
else
return 0
endif
endfun
" Remap <Enter> to split the line and insert a new line in between if
" BreakLine return True
inoremap <expr> <CR> BreakLine() ? "<CR><ESC>O" : "<CR>"
" integrate ranger file browser
function! RangeChooser()
let temp = tempname()
" The option "--choosefiles" was added in ranger 1.5.1. Use the next line
" with ranger 1.4.2 through 1.5.0 instead.
"exec 'silent !ranger --choosefile=' . shellescape(temp)
if has("gui_running")
exec 'silent !xterm -e ranger --choosefiles=' . shellescape(temp)
else
exec 'silent !ranger --choosefiles=' . shellescape(temp)
endif
if !filereadable(temp)
redraw!
" Nothing to read.
return
endif
let names = readfile(temp)
if empty(names)
redraw!
" Nothing to open.
return
endif
" Edit the first item.
exec 'edit ' . fnameescape(names[0])
" Add any remaning items to the arg list/buffer list.
for name in names[1:]
exec 'argadd ' . fnameescape(name)
endfor
redraw!
endfunction
command! -bar RangerChooser call RangeChooser()
nnoremap <leader>- :<C-U>RangerChooser<CR>
" Auto semi colon
" If there isn't one, append a semi colon to the end of the current line.
" function s:appendSemiColon()
" if getline('.') !~ ';$'
" let original_cursor_position = getpos('.')
" exec("s/$/;/")
" call setpos('.', original_cursor_position)
" endif
" endfunction
" For programming languages using a semi colon at the end of statement.
" augroup infosec03
" autocmd!
" autocmd FileType c,cpp,css,java,javascript,perl,php nmap <silent><leader>\ :call <SID>appendSemiColon()<cr>
" augroup end
" inoremap ;; <C-o>A;
" nnoremap <leader>\ :normal A;<CR>
" Append modeline after last line in buffer.
" Use substitute() instead of printf() to handle '%%s' modeline in LaTeX
" files.
function! AppendModeline()
let l:modeline = printf(" vim: set ft=sh ts=%d sw=%d tw=%d fdm=marker fdl=0 fen :",
\ &tabstop, &shiftwidth, &textwidth)
let l:modeline = substitute(&commentstring, "%s", l:modeline, "")
call append(line("$"), l:modeline)
endfunction
nnoremap <silent> <Leader>ml :call AppendModeline()<CR>
" reload in vim dev mode
if !exists('*Makehsd')
function! Makehsd()
let $HSDVIM="dev"
source $MYVIMRC
endfun
endif
nnoremap <silent> <leader>5 :call Makehsd()<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Filetypes and Completions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
augroup OmniCompletionSetup
autocmd!
autocmd FileType c set omnifunc=ccomplete#Complete
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType python set omnifunc=jedi#completions
autocmd FileType ruby set omnifunc=rubycomplete#Complete
" javascript
" autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType javascript set omnifunc=tern#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
augroup END
augroup allFiles
autocmd!
" autocmd BufEnter * if &filetype == "conf" | setlocal ft=markdown | endif
" autocmd BufNewFile,BufRead /home/ubuntu/notes/* set wrap ft=markdown
autocmd BufRead *.txt set tw=80
autocmd BufRead ~/.mutt/temp/mutt-* set tw=80 ft=mail nocindent spell
autocmd FileType c,cpp,h set sw=8 ts=8 sts=8 noexpandtab makeprg=make
autocmd FileType perl set sw=4 ts=4 sts=4 makeprg=perl\ %
autocmd FileType java set sw=4 ts=4 sts=4 makeprg=javac\ %
autocmd FileType votl set sw=2 ts=2 sts=2 list
autocmd FileType votl colorscheme molokai
autocmd FileType lua set sw=4 ts=4 sts=4 makeprg=lua\ %
autocmd FileType python setlocal expandtab ts=4 sw=4 sts=4 list makeprg=python\ %
autocmd FileType ruby set sw=2 ts=2 sts=2 list makeprg=ruby\ %
autocmd FileType sh set sw=2 ts=2 sts=2 list makeprg=./%
autocmd FileType html setlocal sw=2 ts=2 sts=2 foldenable foldmethod=indent foldlevel=6 list
autocmd FileType jade set sw=2 ts=2 sts=2 foldenable foldmethod=indent foldlevel=6 list
autocmd FileType pug set sw=2 ts=2 sts=2 foldenable foldmethod=indent foldlevel=6 list
autocmd FileType stylus set sw=2 ts=2 sts=2 foldenable foldmethod=indent foldlevel=0 list
autocmd FileType css set sw=2 ts=2 sts=2 foldenable foldmethod=indent foldlevel=6 nolist
autocmd FileType javascript set sw=2 ts=2 sts=2 foldenable foldmethod=indent foldlevel=6 list
autocmd FileType jsx set sw=2 ts=2 sts=2 foldenable foldmethod=indent foldlevel=6 list
autocmd FileType yaml set sw=2 ts=2 sts=2 list
augroup END
" Miscellaneous file types.
augroup infosec04
autocmd!
autocmd BufNewFile,BufRead *.babelrc set filetype=javascript
autocmd BufNewFile,BufRead *.eslintrc,.reduxrc set filetype=json
autocmd BufNewFile,BufRead gitconfig set filetype=gitconfig
autocmd BufNewFile,BufRead *.prettierrc set filetype=yaml
autocmd BufNewFile,BufRead *.svelte set filetype=html syntax=html
augroup end
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => LeaderMappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nnoremap <leader>k :b#<CR>
nnoremap <leader>n :BufExplorer<CR>
nnoremap <silent> <Leader>x :Bdelete<CR>
nnoremap <leader>o :Files<CR>
nnoremap <bar> :Buffers<CR>
" nnoremap \ :Lines<CR>
nnoremap <leader>t :Tags<CR>
nnoremap <leader>` :Marks<CR>
nnoremap <leader>z :cclose<CR>
nnoremap <leader>c :close<CR>
" search word in project
nnoremap <leader>j mO :Ack! "\b<cword>\b" <CR>
" tpope/vim-projectionist
nnoremap <Leader>pp :Eview
nnoremap <Leader>aa :A<CR>
nnoremap <Leader>av :AV<CR>
nnoremap <leader>e :edit <c-r>=expand("%:p:h")<cr>/
nnoremap <silent> <Leader>\b :Buffers<CR>
nnoremap <silent> <Leader>\f :Files<CR>
nnoremap <silent> <Leader>\l :Lines<CR>
nnoremap <silent> <Leader>\F :GFiles<CR>
nnoremap <silent> <Leader>\g :GFiles?<CR>
nnoremap <silent> <Leader>\h :History:<CR>
nnoremap <silent> <Leader>\H :Helptags<CR>
nnoremap <silent> <Leader>\m :Maps<CR>
nnoremap <Leader>\r :Rg
nnoremap <silent> <Leader>\/ :History/<CR>
nnoremap <silent> <Leader>\: :Commands<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Useful
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Yank smart, to be consistent with C and D
nnoremap Y y$
" use these to escape in insert more
" imap jk <Esc>
" imap kj <Esc>
" C-a to select all
nnoremap <C-a> ggVG
inoremap <C-a> ggVG
" U: Redos since 'u' undos
nnoremap U :redo<cr>
" fast exit
" nmap qq :qa<CR>
"nnoremap <silent> <Leader>q :qa<CR>
" Fix annoying surround.vim message
vmap s S
" Use local vimrc if available {
"if filereadable($HOME.'/.vimrc-local')
" source $HOME/.vimrc-local
"endif
" nice copy paste functionality
vnoremap <silent> y y`]
vnoremap <silent> p p`]
nnoremap <silent> p p`]
" my mappings more
nnoremap <BS> :
" save with enter
" nnoremap <Enter> :w<CR>
nnoremap <expr> <cr> &modified ? ":call FlashSave()<cr><cr>" : "<cr>"
" fast whole file alignment
nnoremap <leader>= gg=G``
" Ctrl+A goes to the front of the command line
cnoremap <C-A> <Home>
" Ctrl+E goes to the end of the command line
cnoremap <C-E> <End>
" move to beginning/end of line
nnoremap B ^
nnoremap E $
" highlight last inserted text
nnoremap gv `[v`]
" Jump to the last edited palce
nnoremap ge `.
nnoremap ; q:i
nnoremap : ;
vnoremap ; q:i
vnoremap : ;
nnoremap / q/i
nnoremap ? q?i
nnoremap Q @q
vnoremap Q :norm @q<cr>
if &diff
nnoremap <leader>1 :diffget LOCAL
nnoremap <leader>2 :diffget BASE
nnoremap <leader>3 :diffget REMOTE
endif
nnoremap <silent> <leader>mm :set modeline \| doautocmd BufRead<CR>
" disable folding"
set nofoldenable
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => ModeMappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Insert Mode
"=========================
" Ctrl-e: Go to end of line
inoremap <c-e> <esc>A
" Ctrl-a: Go to begin of line
inoremap <c-a> <esc>I
" Ctrl-f: Move cursor left
inoremap <c-f> <Right>
" Ctrl-c: Inserts line below
inoremap <c-c> <c-o>o
" Ctrl-v: Paste. Advanced
" imap <C-v> <ESC>"+pa
inoremap <c-v> <c-g>u<c-o>gP
" Visual Mode
"=========================
"x = visual only
" Backspace: Delete selected and go into insert mode
xnoremap <bs> c
" Tab: Indent
xmap <Tab> >
" shift-tab: unindent
xmap <s-tab> <
" copy and paste
vmap <C-c> "+y
vmap <C-x> "+x
vmap <C-v> c<ESC>"+p
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugins - normal
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" mileszs/ack.vim
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
" milkypostman/vim-togglelist
let g:toggle_list_no_mappings=1
nnoremap <script> <silent> <leader>7 :call ToggleQuickfixList()<CR>
nnoremap <script> <silent> <leader>8 :call ToggleLocationList()<CR>
" alvan/vim-closetag
let g:closetag_filenames = "*.xml,*.html,*.xhtml,*.phtml,*.php,*.erb,*,js,*.jsx"
let g:mta_filetypes = {
\ 'html' : 1,
\ 'javascript.jsx' : 1,
\ 'jinja' : 1,
\ 'liquid' : 1,
\ 'markdown' : 1,
\ 'xhtml' : 1,
\ 'xml' : 1,
\}
let g:closetag_xhtml_filenames = '*.xhtml,*.jsx,*.erb'
let g:closetag_emptyTags_caseSensitive = 1
" Raimondi/delimitMate
au FileType xml,html,phtml,php,xhtml,js,erb,jsx let b:delimitMate_matchpairs = "(:),[:],{:}"
" mileszs/ack.vim
nnoremap <leader>a :Gack
nnoremap <leader>A :Ack!
function! Find_git_root()
return system('git rev-parse --show-toplevel 2> /dev/null')[:-2]
endfunction
command! -nargs=1 Gack execute "Ack! <args> " . Find_git_root()
"command! -nargs=* Gack :execute 'Ack! ' . expand('<args>') '%:p:h'
" plasticboy/vim-markdown
let g:vim_markdown_folding_disabled = 1
" let g:vim_markdown_folding_level = 4
" let g:vim_markdown_conceal = 0
" lambdalisue/vim-foldround
nmap <Leader>ff <Plug>(foldround-forward)
nmap <Leader>fb <Plug>(foldround-backward)
" **********
" * New 2019
" **********
" svermeulen/vim-cutlass
" ********
" nnoremap x d
" xnoremap x d
" nnoremap xx dd
" nnoremap X D
"vnoremap X ygvD
"vnoremap xx ygvD
nnoremap m d
xnoremap m d
nnoremap mm dd
nnoremap M D
" ********
" svermeulen/vim-yoink
" ********
nmap <c-n> <plug>(YoinkPostPasteSwapBack)
"nmap <c-p> <plug>(YoinkPostPasteSwapForward)
nmap <expr> <c-p> yoink#isSwapping() ? '<plug>(YoinkPostPasteSwapForward)' : ':FZF'
nmap p <plug>(YoinkPaste_p)
nmap P <plug>(YoinkPaste_P)
nmap <c-=> <plug>(YoinkPostPasteToggleFormat)
nmap y <plug>(YoinkYankPreserveCursorPosition)
xmap y <plug>(YoinkYankPreserveCursorPosition)
"let g:yoinkSyncNumberedRegisters = 1
let g:yoinkIncludeDeleteOperations = 1
" ********
" svermeulen/vim-subversive
" ********
" s for substitute
nmap s <plug>(SubversiveSubstitute)
nmap ss <plug>(SubversiveSubstituteLine)
nmap S <plug>(SubversiveSubstituteToEndOfLine)
nmap <leader>cr <plug>(SubversiveSubstituteRangeConfirm)
xmap <leader>cr <plug>(SubversiveSubstituteRangeConfirm)
nmap <leader>crr <plug>(SubversiveSubstituteWordRangeConfirm)
xmap s <plug>(SubversiveSubstitute)
xmap p <plug>(SubversiveSubstitute)
xmap P <plug>(SubversiveSubstitute)
" ********
" kana/vim-textobj-user
" ********
" ie = inner entire buffer
onoremap ie :exec "normal! ggVG"<cr>
" iv = current viewable text in the buffer
onoremap iv :exec "normal! HVL"<cr>
" ********
" lfilho/cosco.vim
" ********
autocmd FileType javascript,css,jsx nmap <silent> <Leader>\ <Plug>(cosco-commaOrSemiColon)
autocmd FileType javascript,css,jsx imap <silent> <Leader>\ <c-o><Plug>(cosco-commaOrSemiColon)
let g:cosco_filetype_whitelist = ['css', 'javascript', 'jsx']
" *****************
" mhinz/vim-grepper
" *****************
let g:grepper={}
let g:grepper.tools=["rg"]
" xmap gr <plug>(GrepperOperator)
" After searching for text, press this mapping to do a project wide find and
" replace. It's similar to <leader>r except this one applies to all matches
" across all files instead of just the current file.
nnoremap <Leader>R
\ :let @s='\<'.expand('<cword>').'\>'<CR>
\ :Grepper -cword -noprompt<CR>
\ :cfdo %s/<C-r>s//g \| update
\<Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left>
" use alt-a to select all in quick window
nnoremap <Leader>RR
\ :let @s='\<'.expand('<cword>').'\>'<CR>
\ :cfdo %s/<C-r>s//g \| update
\<Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left>
" Allow passing optional flags into the Rg command.
" Example: :Rg myterm -g '*.md'
command! -bang -nargs=* Rg call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case " . <q-args>, 1, <bang>0)
" ********
" vimux
" ********
" Prompt for a command to run
nnoremap <leader>vp :VimuxPromptCommand<CR>
" Run last command executed by VimuxRunCommand
nnoremap <leader>vl :VimuxRunLastCommand<CR>