-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvimrc.keymap
598 lines (474 loc) · 15.3 KB
/
vimrc.keymap
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
nnoremap ; :
" No HELP
noremap <F1> <Esc>
inoremap <F1> <Esc>
if !exists('g:hardcore_mode')
" Save file
imap <F2> <C-o>:w<CR>
vmap <F2> :<C-U>w<CR>v
nmap <F2> :w<CR>
" Save all files
imap <C-F2> <C-o>:wa<CR>
vmap <C-F2> :<C-U>wa<CR>v
nmap <C-F2> :wa<CR>
" Save file as...
imap <S-F2> <C-o>:w<SPACE><C-R>=expand("%:p")<CR>
vmap <S-F2> :<C-U>w<SPACE><C-R>=expand("%:p")<CR>
nmap <S-F2> :w<SPACE><C-R>=expand("%:p")<CR>
" Delete line without yank
noremap <C-y> "_dd
inoremap <C-y> <C-o>"_dd
" Delete char without yank
nnoremap <Del> "_x
inoremap <Del> <C-o>"_x
" Delete line to EOL
map <C-l> d$
imap <C-l> <C-o>d$
" Delete line to BOL
map <C-h> d^
imap <C-h> <C-o>d^
" Toggle readonly mode
map <silent> <F4> <Esc>:call ToggleReadonly()<CR>
vnoremap <silent> <F5> :sort<CR>
" Open definition in new tab
map <C-b> <C-w>gf
imap <C-b> <C-o><C-w>gf
" Folding
inoremap <F9> <C-O>za
nnoremap <F9> za
onoremap <F9> <C-C>za
inoremap <S-F9> <C-O>zA
nnoremap <S-F9> zA
onoremap <S-F9> <C-C>zA
if exists('g:tools_tagbar')
map <C-g> :TagbarToggle<CR>
imap <C-g> <C-o>:TagbarToggle<CR>
endif
if exists('g:tools_commenter')
" Ctrl-\ - Comment current line or selection.
map <C-\> ,ci
imap <C-\> <C-o>,ci
endif
if exists('g:tools_undotree')
map <C-z> :UndotreeToggle<CR>
imap <C-z> <C-o>:UndotreeToggle<CR>
endif
if exists('g:tools_ctrlp')
nnoremap <silent> <C-p> :CtrlPMenu<CR>
vnoremap <silent> <C-p> <C-U>:CtrlPMenu<CR>
inoremap <silent> <C-p> <C-o>:CtrlPMenu<CR>
nnoremap <silent> <C-p>p :CtrlPCmdPalette<CR>
vnoremap <silent> <C-p>p <C-U>:CtrlPCmdPalette<CR>
inoremap <silent> <C-p>p <C-o>:CtrlPCmdPalette<CR>
endif
if exists('g:tools_nerdtree')
map <silent> <C-d> :NERDTreeToggle<CR>
imap <silent> <C-d> <C-o>:NERDTreeToggle<CR>
map <silent> <C-f> :NERDTree<CR><C-w>p:NERDTreeFind<CR>
imap <silent> <C-f> <C-o>:NERDTree<CR><C-w>p:NERDTreeFind<CR>
endif
if exists('g:tools_vimfiler')
map <silent> <C-d> :VimFilerExplorer<CR>
imap <silent> <C-d> <C-o>:VimFilerExplorer<CR>
map <silent> <C-f> :VimFilerExplorer -find<CR>
imap <silent> <C-f> <C-o>:VimFilerExplorer -find<CR>
endif
if !has("gui_running")
if (&readonly || argc() || !isdirectory(argv(0))) && !exists("s:std_in")
noremap <silent> <Esc><Esc> :qa<CR>
inoremap <silent> <Esc><Esc> <Esc>:qa<CR>
else
if exists('g:tab_mode')
noremap <silent> <Esc><Esc><Esc> :bd<CR>
inoremap <silent> <Esc><Esc><Esc> <Esc>:bd<CR>
else
noremap <silent> <Esc><Esc><Esc> :call CloseWindowOrKillBuffer()<CR>
inoremap <silent> <Esc><Esc><Esc> <Esc>:call CloseWindowOrKillBuffer()<CR>
endif
endif
else
if exists('g:tab_mode')
noremap <silent> <Esc><Esc> :bd<CR>
inoremap <silent> <Esc><Esc> <Esc>:bd<CR>
else
noremap <silent> <Esc><Esc> :call CloseWindowOrKillBuffer()<CR>
inoremap <silent> <Esc><Esc> <Esc>:call CloseWindowOrKillBuffer()<CR>
endif
endif
imap <F10> <ESC>:qa!<CR>
map <F10> :qa!<CR>
imap <S-F10> <C-o>:wqa!<CR>
map <S-F10> :wqa!<CR>
else
if (&readonly || argc())
noremap <silent> <Esc><Esc> :qa<CR>
inoremap <silent> <Esc><Esc> <Esc>:qa<CR>
end
" Easy window navigation
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
endif
if exists('g:tools_tagbar')
map <leader>g :TagbarToggle<CR>
imap <leader>g <C-o>:TagbarToggle<CR>
endif
if exists('g:tools_undotree')
map <leader>zz :UndotreeToggle<CR>
imap <leader>zz <C-o>:UndotreeToggle<CR>
endif
nmap <F6> :QFix<CR>
imap <F6> <C-o>:QFix<CR>
nmap <S-F6> :LList<CR>
imap <S-F6> <C-o>:LList<CR>
if exists('g:tools_search')
if exists('g:tools_search_fzf')
nmap <leader>sz :FZF <C-R>=expand("%:p:h")<CR>
nmap <S-F7> :FZF <C-R>=expand("%:p:h")<CR>
imap <S-F7> <C-o>:FZF <C-R>=expand("%:p:h")<CR>
end
if exists('g:tools_search_ag')
" Search word under cursor or selected word entire files in current directory (recursively)
nnoremap <silent> <Leader>sf :Ag <cword><CR>
vnoremap <silent> <Leader>sf :<C-U>execute "Ag ".GetVisual()<CR>
nmap <F7> :Ag ""<Left>
imap <F7> <C-o>:Ag ""<Left>
vmap <F7> y:Ag "<C-R>+"<SPACE>"<C-R>=expand("%:p:h")<CR>"
" Open the Ag command and place the cursor into the quotes
nmap <Leader>sa :Ag ""<Left>
nmap <Leader>saf :AgFile ""<Left>
endif
if exists('g:tools_search_flygrep')
nnoremap <Leader>s/ :FlyGrep<CR>
vnoremap <Leader>s/ y:FlyGrep<CR><C-R>+
endif
" Search word under cursor and replace with user inputs in current file
nnoremap <Leader>sr :%s/<C-R>=expand("<cword>")<CR>//<Left>
vnoremap <Leader>sr :<C-U>%s/<C-R>=GetVisual()<CR>//<Left>
nmap <F8> :%s///<Left><Left>
imap <F8> <C-o>:%s///<Left><Left>
vmap <F8> y:%s/<C-R>+//<Left>
endif
if exists('g:tools_commenter')
" Comment/Uncomment current line or selection
map <silent> \\ ,c<Space>
imap <silent> \\ <C-o>,c<Space>
endif
if exists('g:tools_dash')
map <silent> <leader>d <Plug>DashGlobalSearch
endif
if exists('g:tools_align')
vnoremap <silent> <Enter> :EasyAlign<cr>
endif
if exists("g:use_copy_cut_paste_keys")
" CTRL-X and SHIFT-Del are Cut
vnoremap <C-X> "+x
vnoremap <S-Del> "+x
" CTRL-C and CTRL-Insert are Copy
vnoremap <C-C> "+y
vnoremap <C-Insert> "+y
" CTRL-V and SHIFT-Insert are Paste
map <C-V> "+gP
map <S-Insert> "+gP
cmap <C-V> <C-R>+
cmap <S-Insert> <C-R>+
exe 'inoremap <script> <C-V>' paste#paste_cmd['i']
exe 'vnoremap <script> <C-V>' paste#paste_cmd['v']
imap <S-Insert> <C-V>
vmap <S-Insert> <C-V>
" Text selection by SHIFT+Arrows
imap <S-Up> <Esc>v<Up>
imap <S-Down> <Esc>v<Down>
imap <S-Left> <Esc>v<Left>
imap <S-Right> <Esc><Right>v<Right>
nmap <S-Up> v<Up>
nmap <S-Down> v<Down>
nmap <S-Left> v<Left>
nmap <S-Right> v<Right>
vmap <S-Up> <Up>
vmap <S-Down> <Down>
vmap <S-Left> <Left>
vmap <S-Right> <Right>
imap <S-End> <Esc>v<End>
imap <S-Home> <Esc>v<Home>
nmap <S-End> v<End>
nmap <S-Home> v<Home>
vmap <S-End> <End>
vmap <S-Home> <Home>
" Line selection by ALT+SHIFT+Arrows
imap <S-A-Up> <Esc>V<Up>
imap <S-A-Down> <Esc>V<Down>
imap <S-A-Left> <Esc>V<Left>
imap <S-A-Right> <Esc><Right>V<Right>
nmap <S-A-Up> V<Up>
nmap <S-A-Down> V<Down>
nmap <S-A-Left> V<Left>
nmap <S-A-Right> V<Right>
vmap <S-A-Up> <Up>
vmap <S-A-Down> <Down>
vmap <S-A-Left> <Left>
vmap <S-A-Right> <Right>
endif
if exists('g:tools_shell')
map <silent> ~~ :Deol<CR>
endif
" Space for open/close folds if exist
nnoremap <silent> <Leader>f<Space> @=(foldlevel('.')?'za':"\<Space>")<CR>
vnoremap <Leader>f<Space> zf
if exists('g:tab_mode')
noremap <silent> <D-]> gt
noremap <silent> <D-[> gT
inoremap <silent> <D-]> <C-o>gt
inoremap <silent> <D-[> <C-o>gT
else
noremap <silent> <D-]> :bn<CR>
inoremap <silent> <D-]> <C-o>:bn<CR>
noremap <silent> <D-[> :bp<CR>
inoremap <silent> <D-[> <C-o>:bp<CR>
endif
if exists('g:tools_ctrlp')
nnoremap <silent> .. :CtrlPBuffer<cr>
vnoremap <silent> .. <C-U>:CtrlPBuffer<cr>
nnoremap <silent> <Space><Space> :CtrlPtjump<CR>
vnoremap <silent> <Space><Space> :CtrlPtjumpVisual<CR>
nnoremap <silent> pp :CtrlPCmdPalette<CR>
vnoremap <silent> pp <C-U>:CtrlPCmdPalette<CR>
nnoremap <silent> pm :CtrlPMenu<CR>
vnoremap <silent> pm <C-U>:CtrlPMenu<CR>
endif
" If you visually select something and hit paste
" that thing gets yanked into your buffer.
vnoremap p "_dP
" Repeat the last recorded macro
map Q @@
" Easy up and down on wrapped long lines
nnoremap j gj
nnoremap k gk
if !exists('g:use_arrow_keys') && !exists('g:hardcore_mode_with_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>
" When in insert mode, you can move the cursor by using CTRL+h, CRTL+j, CTRL+k or CTRL+l
inoremap <C-h> <C-o>h
inoremap <C-j> <C-o>j
inoremap <C-k> <C-o>k
inoremap <C-l> <C-o>l
else
nnoremap <Down> gj
nnoremap <Up> gk
endif
" A more handy Esc
inoremap jj <Esc>
inoremap kk <Esc>
inoremap jk <Esc>
inoremap kj <Esc>
" Easier increment/decrement
nnoremap + <C-a>
nnoremap - <C-x>
" Jump to start and end of line using the home row keys
noremap H ^
noremap L $
" Replace current line with yanked line
nmap rr ^Pjdd
" Place your cursor on the word you want to search for, start search by typing / and hit Ctrl+Space to insert the word.
cmap <Nul> <C-R><C-W>
" Switch off search highlights
nmap <silent> // :nohlsearch<CR><Esc>
" ,a - select all text in buffer
noremap <Leader>a ggVG
" Split window verticaly
nnoremap <silent> <Leader>vv <C-w>v
" Split window horizontaly
nnoremap <silent> <Leader>hh <C-w>s
" Ctrl-P - Inserts the path of the currently edited file into a command
cmap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
" Insert semeoclon to EOL
" then press <Enter> to add new line below
inoremap ;; <C-o>m`A;<C-o>``a
inoremap ;;<CR> <C-o>A;<C-o>o
nnoremap ;; m"A;<Esc>`"
nnoremap ;;<CR> A;<Esc>o
" Show most plugin keybindings
nnoremap <silent><Leader>? :map <Leader><CR>
noremap <silent> ' :<C-U>call ToggleQuote()<CR>
" Make gf (go to file)
" Create the file if not existent
nnoremap <Leader>gf :e <cfile><CR>
nnoremap <Leader>gfw :sp +e <cfile><CR>
nnoremap <Leader>gft :tabe <cfile><CR>
" Open changed files in current repository
nnoremap <silent> <Leader>ocf :OpenChangedFiles<CR>
" CtrlP filemanager
nnoremap <Leader>o :CtrlP<CR>
" Type <Leader>w to save file (a lot faster than :w<Enter>):
nnoremap <Leader>w :w<CR>
" Type <Leader>wa to save all files (a lot faster than :wa<Enter>):
nnoremap <Leader>wa :wa<CR>
" Type <Leader>w? to save file as ...
nnoremap <Leader>w? :w<SPACE><C-R>=expand("%:p")<CR>
" Type <Leader>wq to save file and close it (a lot faster than :wq<Enter>):
nnoremap <Leader>wq :wq<CR>
" Type <Leader>x to save file and close it (a lot faster than :x<Enter>):
nnoremap <Leader>x :wq<CR>
" Type <Leader>x! to save all files and close VIM (a lot faster than :waq!<Enter>):
nnoremap <Leader>x! :waq!<CR>
" Type <Leader>X to close current file without saving (a lot faster than :q!<Enter>):
nnoremap <Leader>X :q!<CR>
" Type <Leader>X! to close VIM without saving (a lot faster than :qa!<Enter>):
nnoremap <Leader>X! :qa!<CR>
" <Leader>$ Surround a word with ${JS interpolation}
vmap $ c${<C-R>"}<ESC>
" <Leader># Surround a word with #{ruby interpolation}
nmap # ysiw#
vmap # c#{<C-R>"}<ESC>
" <Leader>" Surround a word with "quotes"
nmap " ysiw"
vmap " c"<C-R>""<ESC>
" <Leader>' Surround a word with 'single quotes'
nmap ' ysiw'
vmap ' c'<C-R>"'<ESC>
" <Leader>) or <Leader>( Surround a word with (parens)
" The difference is in whether a space is put in
nmap ( ysiw(
nmap ) ysiw)
vmap ( c( <C-R>" )<ESC>
vmap ) c(<C-R>")<ESC>
" <Leader>[ Surround a word with [brackets]
nmap ] ysiw]
nmap [ ysiw[
vmap [ c[ <C-R>" ]<ESC>
vmap ] c[<C-R>"]<ESC>
" <Leader>{ Surround a word with {braces}
nmap } ysiw}
nmap { ysiw{
vmap } c{ <C-R>" }<ESC>
vmap { c{<C-R>"}<ESC>
" <Leader>` Surround a word with `apostrophes`
nmap ` ysiw`
vmap ` c`<C-R>"`<ESC>
" Go to last edit location with <Leader>.
nnoremap <Leader>. '.
" Switch between the last two files
nnoremap '' <c-^>
" Set working directory
nnoremap <silent> <leader>cd :cd! %:p:h<CR>
if exists('g:tab_mode')
" Opens a tab edit command with the path of the currently edited file filled
noremap <Leader>ee :tabe <C-R>=expand("%:p:h") . "/" <CR>
else
" Opens an edit command with the path of the currently edited file filled in
noremap <Leader>ee :e <C-R>=expand("%:p:h") . "/" <CR>
endif
" <Leader>qc to toggle quickfix window (where you have stuff like Ag)
" <Leader>qo to open it back up (rare)
nmap <silent> <Leader>qc :cclose<CR>
nmap <silent> <Leader>qo :copen<CR>
" Switch all buffers to tabs
map <silent> <leader>tb :tab :ball<cr>
" Switch all buffers to windows
map <silent> <Leader>sb :sball<CR>
" Visual shifting (does not exit Visual mode)
vnoremap < <gv
vnoremap > >gv
vmap <Tab> >
vmap <S-Tab> <
imap <S-Tab> <C-o><<
" Move visual block
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
" Switch between windows
nnoremap <silent> <Tab> :wincmd w<CR>
nnoremap <silent> <S-Tab> :wincmd W<CR>
" Allow using the repeat operator with a visual selection (!)
vnoremap . :normal .<CR>
" Yank word under cursor
nnoremap <Leader>yw byw
" Yank current line
nnoremap <Leader>yl ^y$
" Swap words
noremap <silent> <Leader>sw <Esc>bdwwP
" Replace words
noremap <silent> <Leader>rw "_diwhp
" Delete blank lines
nnoremap <Leader>db :%g/^$/d<CR>\h
vnoremap <Leader>db :g/^$/d<CR>:setlocal nohls<CR>
" Surround every line in the file with '
nnoremap <Leader>l' :%s/.*/'\0'<CR>:setlocal nohls<CR>
vnoremap <Leader>l' :s/.*/'\0'<CR>:setlocal nohls<CR>
" Surround every line in the file with "
nnoremap <Leader>l" :%s/.*/"\0"<CR>:setlocal nohls<CR>
vnoremap <Leader>l" :s/.*/"\0"<CR>:setlocal nohls<CR>
" Surround every line in the file with ()
nnoremap <Leader>l( :%s/.*/(\0)<CR>:setlocal nohls<CR>
vnoremap <Leader>l( :s/.*/(\0)<CR>:setlocal nohls<CR>
" Surround every line in the file with []
nnoremap <Leader>l[ :%s/.*/[\0]<CR>:setlocal nohls<CR>
vnoremap <Leader>l[ :s/.*/[\0]<CR>:setlocal nohls<CR>
" Surround every line in the file with {}
nnoremap <Leader>l{ :%s/.*/{\0}<CR>:setlocal nohls<CR>
vnoremap <Leader>l{ :s/.*/{\0}<CR>:setlocal nohls<CR>
" Strip trailing whitespace
noremap <silent> <leader>ss :call StripWhitespace()<CR>
" Code folding options
nmap <silent> <leader>f0 :set foldlevel=0<CR>:set foldcolumn=0<CR>
nmap <silent> <leader>f1 :set foldlevel=1<CR>:set foldcolumn=1<CR>
nmap <silent> <leader>f2 :set foldlevel=2<CR>:set foldcolumn=2<CR>
nmap <silent> <leader>f3 :set foldlevel=3<CR>:set foldcolumn=3<CR>
nmap <silent> <leader>f4 :set foldlevel=4<CR>:set foldcolumn=4<CR>
nmap <silent> <leader>f5 :set foldlevel=5<CR>:set foldcolumn=5<CR>
nmap <silent> <leader>f6 :set foldlevel=6<CR>:set foldcolumn=6<CR>
nmap <silent> <leader>f7 :set foldlevel=7<CR>:set foldcolumn=7<CR>
nmap <silent> <leader>f8 :set foldlevel=8<CR>:set foldcolumn=8<CR>
nmap <silent> <leader>f9 :set foldlevel=9<CR>:set foldcolumn=9<CR>
" Git
if exists("g:tools_git")
nnoremap <silent> <leader>gs :Gstatus<CR>
nnoremap <silent> <leader>gd :Gvdiff<CR>
nnoremap <silent> <leader>ga :Git add %<CR>
nnoremap <silent> <leader>gA :Git add .<CR>
nnoremap <silent> <leader>g? :Git add <C-R>=expand("%:p:h") . "/"<CR>
nnoremap <silent> <Leader>gb :Gblame<CR>
endif
if exists('g:tools_nerdtree')
map <silent> <Leader>nd :NERDTreeToggle<CR>
" Show current file in NERDTree
map <silent> <Leader>nf :NERDTree<CR><C-w>p:NERDTreeFind<CR>
endif
" Insert new line before current line
nnoremap <Leader><Up> O<ESC>j
" Insert new line after current line
nnoremap <Leader><Down> o<ESC>k
" Toggle show Space/Tab/EOL
nmap <silent> <leader><CR> :set list!<CR>
" Insert new line with '=' after current line with the same length
nnoremap <leader>= yypVr=
" Insert new line with '-' after current line with the same length
nnoremap <leader>- yypVr-
if exists('g:apperances_startscreen')
map <silent> <Leader>bh :Startify<CR>
endif
if exists('g:tab_mode')
map <silent> gf <C-w>gf
map <silent> gF <C-w>gF
map <D-A-Down> <C-w>gf
map <D-A-S-Down> <C-w>gF
endif
if exists('g:tools_ctrlp')
nmap <silent> <D-0> :CtrlPBuffer<CR>
imap <silent> <D-0> <C-o>:CtrlPBuffer<CR>
endif
map <silent> <leader>bq :bp <BAR> bd #<CR>
map <silent> <leader>bd :bd<CR>
map <silent> <Leader>bp :bp<CR>
map <silent> <Leader>bn :bn<CR>
" Undo/Redo
nnoremap <D-z> u
inoremap <D-z> <C-o>u
nnoremap <D-S-z> <C-r>
inoremap <D-S-z> <C-o><C-r>