-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.vimrc
2399 lines (2225 loc) · 92.6 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
"=========================================================================
" DesCRiption: 适合自己使用的vimrc文件,for Linux/Mac, GUI/Console
" Last Change: 2019年03月04日
" Version: 0.1
" Source:
" =========================================================================
" 加载插件配置文件
if filereadable(expand("~/.vimrc.bundles"))
source ~/.vimrc.bundles
endif
" let g:ycm_log_level = 'debug'
"-----------------------------------------------------------------
" 基础设置
"-----------------------------------------------------------------
if has('syntax') && !exists('g:syntax_on') | syntax enable | endif " 开语法高亮
set winminheight=0
set winminwidth=0
let g:python_highlight_all = 1 " 开启python的所有语法高亮,插件'hdima/python-syntax'
set showcmd " 右下角:n模式显示已输入命令;v模式显示选区范围
set showmode " 左下角的状态栏显示INSERT之类的字样
set nocompatible " 关闭 vi 兼容模式
set number " 显示行号
set cursorline " 突出显示当前行
set ruler " 打开状态栏标尺
set nobackup " 覆盖文件时不备份
set autochdir " 自动切换当前目录为当前文件所在的目录
set backupcopy=yes " 设置备份时的行为为覆盖
set ignorecase smartcase " 搜索时忽略大小写(ignorecase),但在有一个或以上大写字母时仍保持对大小写敏感(smartcase)
" set nowrapscan " 禁止在搜索到文件两端时重新搜索
set incsearch " 输入搜索内容时就显示搜索结果
set hlsearch " 搜索时高亮显示被找到的文本
set noerrorbells " 关闭错误信息响铃
set novisualbell " 关闭使用可视响铃代替呼叫
set t_vb= " 置空错误铃声的终端代码
set showmatch " 插入括号时,短暂地跳转到匹配的对应括号
set matchtime=1 " 短暂跳转到匹配括号的时间(单位秒)
set magic " 设置魔术
set hidden " 允许在有未保存的修改时切换缓冲区,此时的修改由 vim 负责保存
set guioptions-=T " 隐藏工具栏
set guioptions-=m " 隐藏菜单栏
" set smartindent " 开启新行时使用智能自动缩进;适用C风格的语言,开启此选项,则以”#“开头的句子,无法用'>>'命令右缩进
set backspace=indent,eol,start " 不设定在插入状态无法用退格键和 Delete 键删除回车符
set cmdheight=1 " 设定命令行的行数为 1
set laststatus=2 " 显示状态栏 (默认值为 1, 无法显示状态栏)
set timeout " mapping的时长限制
set timeoutlen=1000 " 单位毫秒,默认值1000
set ttimeout " 收到键码串的时长限制,例如escape sequance
set ttimeoutlen=50 " 察觉不到的小值,键码串必需50ms内收到,不然当断开处理
set nobackup " no backup files
set noswapfile " no swap(缓冲文件) files
set nowritebackup " only in case you don't want a backup file while editing
set noundofile " no undo files
" BufNewFile : 在窗口创建新文件
" BufRead : 窗口加载文件
" BufEnter : 进入窗口。可以反复进出同一个窗口,每次进入时都会触发。
autocmd BufNewFile,BufEnter * filetype detect | if &filetype==#'leaderf' | stopinsert | endif
autocmd BufNewFile,BufEnter * if @%==#'__CtrlSF__' | stopinsert | endif
autocmd BufNewFile,BufEnter * if @%=~#'FAR [0-9]\+' | stopinsert | endif
autocmd BufNewFile,BufEnter * if &readonly | stopinsert | endif
" autocmd BufNewFile,BufEnter * if (@%!~#'/LeaderF$' && @%!=#'__CtrlSF__' && @%!~#'FAR [0-9]\+' && !&readonly) | startinsert | endif
autocmd BufNewFile,BufReadPost * filetype detect | if ( &filetype!=#'leaderf' && @%!=#'__CtrlSF__' && @%!~#'FAR [0-9]\+' && !&readonly ) | startinsert | endif " 默认使用插入模式
" 让vim记忆上次编辑的位置
autocmd BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
" 显示行尾的^M(由windows创建的文件会包含)
autocmd BufReadPost * edit ++ff=unix
" autocmd BufNewFile,BufEnter * call writefile([@%.' '.&filetype], $HOME."/vim.bufenter.log", "a")
" autocmd BufRead,BufNewFile,BufEnter * filetype detect " 开vim即检查文件类型
"
set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}3?\ %c:%l/%L%)\
" 设置在状态行显示的信息
if has('mouse') | set mouse=a | endif " 启用鼠标
noremap <C-n> :set invnumber<CR>| " 开关行号
" if $TERM_PROGRAM =~ "iTerm"
let &t_SI = "\<Esc>]50;CursorShape=1\x7" " 插入模式改为细光标
let &t_SR = "\<Esc>]50;CursorShape=2\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7" " 其他模式还是粗光标
" endif
" 在退出nvim后恢复终端原来的光标形态
if has('nvim')
autocmd VimLeave * set guicursor= | call chansend(v:stderr, "\x1b[ q")
endif
" 光标闪烁
set guicursor+=a:blinkon1
map ᜪ <c-;>
map! ᜪ <c-;>
noremap <c-;> :|
inoremap <c-;> <c-o>:| " ctrl+; 开始命令模式
let mapleader = ',' " 修改leader
"-----------------------------------------------------------------
" 折叠
"-----------------------------------------------------------------
set foldenable " 开始折叠
set foldmethod=syntax " 设置语法折叠
set foldcolumn=0 " 设置折叠区域的宽度
setlocal foldlevel=1 " 设置折叠层数为
" set foldclose=all " 设置为自动关闭折叠
" 用ctrl+=键来开关折叠
nnoremap <silent> <c-=> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
vnoremap <silent> <expr> <c-=> foldclosed(line('.')) < 0 ? 'zc' : 'zo'
inoremap <silent> <expr> <c-=> foldclosed(line('.')) < 0 ? '<c-o>zc' : '<c-o>zo'
" iterm2将 ctrl+= 映射成 ᜂ vim再将其映射为<c-=>
map ᜂ <c-=>
map! ᜂ <c-=>
"-----------------------------------------------------------------
" 路径设置
"-----------------------------------------------------------------
" return OS type, eg: windows, or linux, mac, et.st..
function! MySys()
if has("win16") || has("win32") || has("win64") || has("win95")
return "windows"
elseif has("unix")
return "linux"
endif
endfunction
" 用户目录变量$VIMFILES
if MySys() == "windows"
let $VIMFILES = $VIM.'/vimfiles'
elseif MySys() == "linux"
let $VIMFILES = $HOME.'/.vim'
endif
" 设定doc文档目录
let helptags=$VIMFILES.'/doc'
" 设置字体 以及中文支持
if has("win32")
set guifont=Inconsolata:h12:cANSI
endif
" -----------------------------------------------------------------
" 配置多语言环境
if has("multi_byte")
" UTF-8 编码
set encoding=utf-8
set termencoding=utf-8
set formatoptions+=mM
set fileencoding=utf-8
scriptencoding utf-8
set fencs=utf-8,gbk
if v:lang =~? '^\(zh\)\|\(ja\)\|\(ko\)'
set ambiwidth=double
endif
if has("win32")
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
language messages zh_CN.utf-8
endif
else
echoerr "Sorry, this version of (g)vim was not compiled with +multi_byte"
endif
"-----------------------------------------------------------------
" 不同操作系统的文件格式下的换行符
" dos <CR> <NL>
" unix <NL>
" mac <CR>
set fileformats=unix,dos,mac
" 支持多种文件格式在vim中显示,进行自动检测:
" 全文无<NL>: 用mac格式
" 有<NL>,第一个 <NL>前有<CR>: 用DOS格式
" 有<NL>,第一个 <NL>前无<CR>: 用unix格式
" 用dos文件格式显示
nmap <leader>fd :set fileformat=dos<CR>
" 用unix文件格式显示
nmap <leader>fu :set fileformat=unix<CR>
"-----------------------------------------------------------------
" vim-airline 界面布局和配色
" 字体设置
set guifont=Meslo\ LG\ S\ DZ\ for\ Powerline:h12
" 如果运行的不是GUI(即MacVim),才启用Airline的Powerline字符
if has('gui_running')
" macvim 的滚动(scrollbar)条颜色不搭,关闭之
set guioptions-=L
set guioptions-=r
endif
let g:airline#extensions#tabline#enabled = 1 " 标签页栏美化
let g:airline#extensions#branch#enabled=1 " 显示 git 分支
let g:airline#extensions#hunks#enabled=0 " ' +n ~m -k '显示在 git 分支左侧, 表示增/改/删的行数
" 它和‘保存时删除行尾空字符’ 兼容不好,若二者皆开,则保存文件时' +n ~m -k '会闪烁多次
let g:airline_theme='gruvbox' " 状态栏配色
" let g:airline_theme='gruvbox_material' " 状态栏配色
" 其他方案搭配
" (colorscheme, airline_theme) = (vimmy_molokai, badwolf) | (gruvbox,gruvbox)
" 安装airline配色方案: Plug 'morhetz/gruvbox'
let g:airline#extensions#tabline#show_buffers = 0 " 不显示已关tab的遗骸
let g:airline_powerline_fonts=1
" ----------------------------------------------------------------
" 编辑区配色
" Plug 'sainnhe/gruvbox-material' " 不好看, 但背景默认透明
" set bg=dark " 背景设置为dark色
" let g:gruvbox_material_transparent_background = 1
" let g:gruvbox_material_background = 'soft'
" colorscheme gruvbox-material
" Plug 'morhetz/gruvbox' " 好看
colorscheme gruvbox " 设定配色方案, 其他备选 Monokai my_molokai gruvbox
" 透明背景
autocmd VimEnter * hi Normal guibg=NONE ctermbg=NONE
set bg=dark " 背景设置为dark色
"-----------------------------------------------------------------
" help
" :h 纵向分整个查看 显示在右侧的分屏
augroup helpfiles
au!
au BufRead,BufEnter */doc/* wincmd L
augroup END
nnoremap <c-h> :h<space>
vnoremap <c-h> :<c-u>h<space>
inoremap <c-h> <c-o>:h<space>
"-----------------------------------------------------------------
"一些不错的映射转换语法(如果在一个文件中混合了不同语言时有用)
" 关闭<c-b>按键,把它作为多种快捷键的leader
" nnoremap <expr> <esc> ''
" vnoremap <expr> <esc> ''
" inoremap <expr> <esc> ''
nnoremap <esc>.p :set filetype=python<CR>
vnoremap <esc>.p <esc>:set filetype=python<CR>gv
inoremap <esc>.p <c-o>:set filetype=python<cr>
nnoremap <esc>.c :set filetype=cpp<cr>
vnoremap <esc>.c <esc>:set filetype=cpp<cr>gv
inoremap <esc>.c <c-o>:set filetype=cpp<cr>
nnoremap <esc>.m :set filetype=matlab<cr>
vnoremap <esc>.m <esc>:set filetype=matlab<cr>gv
inoremap <esc>.m <c-o>:set filetype=matlab<cr>
nnoremap <esc>.s :set filetype=bash<cr>
vnoremap <esc>.s <esc>:set filetype=bash<cr>gv
inoremap <esc>.s <c-o>:set filetype=bash<cr>
nnoremap <esc>.0 :filetype detect<cr>
vnoremap <esc>.0 <esc>:filetype detect<cr>gv
inoremap <esc>.0 <c-o>:filetype detect<cr>
" i更多语言高亮:xhtml, css, javascript, php
"-----------------------------------------------------------------
" 语言专属设置
" 让 Tohtml 产生有 CSS 语法的 html
" syntax/2html.vim,可以用:runtime! syntax/2html.vim
let html_use_css=1
" 运行python代码
autocmd FileType python map <F12> :!python %<CR>
" 打开javascript折叠
let b:javascript_fold=1
" 打开javascript对dom、html和css的支持
let javascript_enable_domhtmlcss=1
" 设置字典 ~/.vim/dict/文件的路径
autocmd filetype javascript set dictionary=$VIMFILES/dict/javascript.dict
autocmd filetype css set dictionary=$VIMFILES/dict/css.dict
autocmd filetype php set dictionary=$VIMFILES/dict/php.dict
"=========================================================================
" 标签页、窗口、buffer操作
"=========================================================================
" 标签页
" alt+t 新开一空标签页
nnoremap † :tabnew<CR>
vnoremap † <esc>:tabnew<CR>v
inoremap † <c-o>:tabnew<CR>
" 开一个文件到新标签页
" <esc> alt+t
nnoremap <esc>† :tabedit<space>
vnoremap <esc>† <esc>:tabedit<space>
inoremap <esc>† <c-o>:tabedit<space>
" shift+left 左一个标签页
nnoremap <S-Left> :tabprev<CR>
vnoremap <S-Left> <esc>:tabprev<CR>v
inoremap <S-Left> <c-o>:tabprev<CR>
" shift+right 右一个标签页
nnoremap <S-Right> :tabnext<CR>
vnoremap <S-Right> <esc>:tabnext<CR>v
inoremap <S-Right> <c-o>:tabnext<CR>
"-----------------------------------------------------------------
" alt 开文件
" alt+n (需事先手动保存)关闭本buffer,并开一个新buffer
nnoremap ᜩ :bd\|enew<cr>
vnoremap ᜩ <esc>:bd\|enew<cr>
inoremap ᜩ <c-o>:bd\|enew<cr>
" <esc>ctrl+n (需要事前手动保存)关闭本buffer,开一个文件到新buffer
nnoremap <esc>ᜩ :bd\|edit<space>
vnoremap <esc>ᜩ <esc>:bd\|edit<space>
inoremap <esc>ᜩ <c-o>:bd\|edit<space>
"-----------------------------------------------------------------
" ctrl+alt: buffer操作
"-----------------------------------------------------------------
" nnoremap ᜩ :update<cr>:bd!|enew<cr>
" vnoremap ᜩ <esc>:update<cr>:bd!|enew<cr>
" inoremap ᜩ <c-o>:update<cr><c-o>:bd!|enew<cr>
" alt+ctrl+n 开一空白个新buffer
nnoremap ᜦ :update<cr>:enew<cr>
vnoremap ᜦ <esc>:update<cr>:enew<cr>
inoremap ᜦ <c-o>:update<cr><c-o>:enew<cr>
" <esc>alt+crtl+n 开一个文件为新buffer
nnoremap <esc>ᜦ :update<cr>:edit<space>
vnoremap <esc>ᜦ <esc>:update<cr>:edit<space>
inoremap <esc>ᜦ <c-o>:update<cr><c-o>:edit<space>
" alt+ctrl+b
nnoremap ᜧ :update<cr>:buffers<cr>
vnoremap ᜧ <esc>:update<cr>:buffers<cr>
inoremap ᜧ <c-o>:update<cr><c-o>:buffers<cr>
" alt+ctrl+[
nnoremap ᜥ :update<cr>:bnext<CR>
vnoremap ᜥ <esc>:update<cr>:bnext<CR>
inoremap ᜥ <c-o>:update<cr><c-o>:bnext<CR>
" alt+ctrl+]
nnoremap ᜣ :update<cr>:bprevious<CR>
vnoremap ᜣ <esc>:update<cr>:bprevious<CR>
inoremap ᜣ <c-o>:update<cr><c-o>:bprevious<CR>
" alt+ctrl+w 关闭当前buffer
nnoremap ᜨ :bd<CR>
vnoremap ᜨ <esc>:bd<CR>
inoremap ᜨ <c-o>:bd<CR>
"-----------------------------------------------------------------
" alt、ctrl+alt: 窗口操作
"-----------------------------------------------------------------
" 窗口分割
set splitright " 默认开在右侧
" alt+\:垂直分割窗口
nnoremap « :vsp<cr>
vnoremap « <esc>:vsp<cr>v
inoremap « <c-o>:vsp<cr>
" <esc> alt+\:垂直分割窗口 开文件
nnoremap <esc>« :vsp<space>
vnoremap <esc>« <esc>:vsp<space>
inoremap <esc>« <c-o>:vsp<space>
set splitbelow " 默认开在下边
" alt+shift+\:水平分割窗口
nnoremap » :sp<cr>
vnoremap » <esc>:sp<cr>v
inoremap » <c-o>:sp<cr>
" <esc> alt+shift+\:水平分割窗口 开文件
nnoremap <esc>» :sp<space>
vnoremap <esc>» <esc>:sp<space>
inoremap <esc>» <c-o>:sp<space>
" 分屏线从虚线改为实线
" hi VertSplit term=reverse cterm=reverse gui=none
" hi VertSplit guibg=#282828 guifg=#181A1F
set fillchars=vert:│,fold:·
"-----------------------------------------------------------------
" alt+Fn+上下左右:去往上下左右一个窗口
" alt+ctrl+left
map ᜉ <plug>(LWin)
map! ᜉ <plug>(LWin)
noremap <plug>(LWin) <c-w>h
inoremap <plug>(LWin) <c-o><c-w>h
" " 普通终端
" noremap <esc>[1;9H <c-w>h
" inoremap <esc>[1;9H <c-o><c-w>h
" " tmux下
" noremap <esc><esc>[1~ <c-w>h
" inoremap <esc><esc>[1~ <c-o><c-w>h
" alt+ctrl+right
map ᜊ <plug>(RWin)
map! ᜊ <plug>(RWin)
noremap <plug>(RWin) <c-w>l
inoremap <plug>(RWin) <c-o><c-w>l
" 普通终端
" noremap <esc>[1;9F <c-w>l
" inoremap <esc>[1;9F <c-o><c-w>l
" " tmux下
" noremap <esc><esc>[4~ <c-w>l
" inoremap <esc><esc>[4~ <c-o><c-w>l
" alt+ctrl+up
map ᜋ <plug>(UWin)
map! ᜋ <plug>(UWin)
noremap <plug>(UWin) <c-w>k
inoremap <plug>(UWin) <c-o><c-w>k
" noremap <esc><esc>[5~ <c-w>k
" inoremap <esc><esc>[5~ <c-o><c-w>k
" alt+shift+doen
map ᜌ <plug>(DWin)
map! ᜌ <plug>(DWin)
noremap <plug>(DWin) <c-w>j
inoremap <plug>(DWin) <c-o><c-w>j
" noremap <esc><esc>[6~ <c-w>j
" inoremap <esc><esc>[6~ <c-o><c-w>j
"-----------------------------------------------------------------
" 窗口尺寸
" 变宽:alt +
nnoremap <silent> ≠ :exe "vertical resize " . (winwidth(0) * 15/14)<CR>
vnoremap <silent> ≠ <esc>:exe "vertical resize " . (winwidth(0) * 15/14)<CR>gv
inoremap <silent> ≠ <c-o>:exe "vertical resize " . (winwidth(0) * 15/14)<CR>
" 变窄 alt -
nnoremap <silent> – :exe "vertical resize " . (winwidth(0) * 14/15)<CR>
vnoremap <silent> – <esc>:exe "vertical resize " . (winwidth(0) * 14/15)<CR>gv
inoremap <silent> – <c-o>:exe "vertical resize " . (winwidth(0) * 14/15)<CR>
" 变高 shift alt +
nnoremap <silent> ± :exe "resize " . (winheight(0) * 10/9)<CR>
vnoremap <silent> ± <esc>:exe "resize " . (winheight(0) * 10/9)<CR>gv
inoremap <silent> ± <c-o>:exe "resize " . (winheight(0) * 10/9)<CR>
" 变矮 shift alt -
nnoremap <silent> ᜭ :exe "resize " . (winheight(0) * 9/10)<CR>
vnoremap <silent> ᜭ <esc>:exe "resize " . (winheight(0) * 9/10)<CR>gv
inoremap <silent> ᜭ <c-o>:exe "resize " . (winheight(0) * 9/10)<CR>
"=========================================================================
" plugin - NERD_tree.vim 以树状方式浏览系统中的文件和目录
"=========================================================================
" :NERDtree 打开NERD_tree :NERDtreeClose 关闭NERD_tree
" o 打开关闭文件或者目录 t 在标签页中打开
" T 在后台标签页中打开 ! 执行此文件
" p 到上层目录 P 到根目录
" K 到第一个节点 J 到最后一个节点
" u 打开上层目录 m 显示文件系统菜单(添加、删除、移动操作)
" r 递归刷新当前目录 R 递归刷新当前根目录
"-----------------------------------------------------------------
" ctrl+T 开关所有tab的tree
fun! TreeToggle()
let g:TreeOnOpen=!g:TreeOnOpen
let tabid=tabpagenr() " 记录当前tab的编号
tabdo NERDTreeToggle " 所有tab同步开关Tree
exec "tabn ".tabid
" 返回此tab
if g:TreeOnOpen
wincmd p " 移动到前一个 (previous) (上次访问的) 窗口
endif
endf
noremap <c-t> :call TreeToggle()<cr>
inoremap <c-t> <c-o>:call TreeToggle()<cr>
"-----------------------------------------------------------------
let NERDTreeShowHidden=1 " 显示隐藏文件
let NERDTreeWinSize=25 " tree栏宽度
let NERDTreeMapOpenInTab='<ENTER>' " 在tree中,回车将文件开新tab
let g:TreeOnOpen=0 " 开vim、进入新tab 即开nerdtree 且光标移动到文本窗口
"-----------------------------------------------------------------
" 开启vim时自动开启NERDTree
fun! VimEnterAutoCmd()
if g:TreeOnOpen
NERDTree
wincmd p " 移动到前一个 (previous) (上次访问的) 窗口
else
wincmd p " 移动到前一个 (previous) (上次访问的) 窗口
endif
endf
autocmd VimEnter * call VimEnterAutoCmd()
" 进入新tab自动开启NERDTree
fun! BufWinEnterAutoCmd()
if g:TreeOnOpen
" 若 tree插件未加载 或 ( 虽然加载tree插件 但 当前tab无tree窗口)
if exists('g:NERDTree')
if ! g:NERDTree.IsOpen()
NERDTreeMirror
wincmd p " 移动到前一个 (previous) (上次访问的) 窗口
endif
else
NERDTreeMirror
wincmd p " 移动到前一个 (previous) (上次访问的) 窗口
endif
endif
endf
autocmd BufWinEnter * call BufWinEnterAutoCmd()
"-----------------------------------------------------------------
" noremap <c-t> :NERDTreeToggle<CR>
" inoremap <c-t> <c-o>:NERDTreeToggle<CR>
" let s:open_tree_when_open_file=0 " 开vim即开nerdtree
" if s:open_tree_when_open_file
" autocmd VimEnter * NERDTree | wincmd p
" autocmd BufWinEnter * NERDTreeMirror | wincmd p
" else
" autocmd VimEnter * wincmd p " 开vim或tab,默认进入右侧编辑区
" endif
" " 进入一个tab,将光标从tree窗口移到文件窗口
" autocmd BufEnter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
" autocmd VimEnter,BufWinEnter * NERDTreeFind | wincmd p "进入vim时打开NERDTreeFind窗口
" 解决在mac下,tree栏目中每行首显示^G, 这是因为其vim 不支持conceal,更新vim使之支持即可
" let g:NERDTreeNodeDelimiter = "\u00a0"
"=========================================================================
" plugin - NERD_commenter.vim 注释代码用的
"=========================================================================
" let mapleader="," " 把默认的leader从“\”改为“,”
" [count],cc 光标及以下count行逐行添加注释(7,cc)
" [count],cu 光标及以下count行逐行取消注释(7,cu)
" [count],cm 光标及以下count行尝试添加块注释(7,cm)
" [count],c【空格】 标及以下count行加或解注释(7,c【空格】)
" ,cA 在行尾插入 /* */,并且进入插入模式。 这个命令方便写注释。
" 注:count参数可选,无则默认为选中行或当前行
" -----------------------------------------------------------------
" 【数字】ctrl+/ 所选区域加/解注释
" 【数字】缺省则注释所选区域
" 补" 缺省则注释光标及一下【数字】行
" iterm2 把键盘输入的 ctrl+/ 映射成<esc>/
" 这里在把 <esc>/ 映射成 vim中的<c-/>
map ᜀ <c-/>
map! ᜀ <c-/>
" function! NComment()
" let firstLine = line("'<")
" let lastLine = line("'>")
" let theLine = getline('.')
" if ( firstLine ==# lastLine ) && ( theLine =~ "^[ \t]*$" )
" call feedkeys("\<Plug>NERDCommenterToggle$a")
" else
" call feedkeys("\<PLUG>NERDCommenterToggle")
" endif
" endfunction
function! NComment()
let l0=line('.')
let c0=col('.')
let theLine = getline('.')
let len0=len(theLine)
if ( theLine =~ "^[ \t]*$" )
exe "silent normal! :call NERDComment('n', 'Toggle')\<CR>"
startinsert
normal! $
else
exe "silent normal! :call NERDComment('n', 'Toggle')\<CR>"
let len1=len(getline('.'))
call cursor(l0,len1-len0+c0)
endif
endfunction
nnoremap <silent> <C-/> :call NComment()<cr>
" nmap <C-/> <Plug>NERDCommenterToggle
" function! VComment() range
" let firstLine = line("'<")
" let lastLine = line("'>")
" let theLine = getline('.')
" if ( firstLine ==# lastLine ) && ( theLine =~ "^[ \t]*$" )
" call feedkeys("\<Esc>\<Plug>NERDCommenterToggle$a")
" else
" call feedkeys("gv\<PLUG>NERDCommenterTogglegv")
" endif
" endfunction
function! VComment() range
let firstLine = line("'<")
let lastLine = line("'>")
let theLine = getline('.')
let [l1,c1]=getpos("'<")[1:2]
let [l2,c2]=getpos("'>")[1:2]
let len1=len(getline("'<"))
let len2=len(getline("'>"))
if ( firstLine ==# lastLine ) && ( theLine =~ "^[ \t]*$" )
exe "silent normal! :call NERDComment('v', 'Toggle')\<CR>"
startinsert
normal! $
else
exe "silent normal! :call NERDComment('v', 'Toggle')\<CR>"
let len1_=len(getline("'<"))
let len2_=len(getline("'>"))
call setpos("'<",[0,l1,len1_-len1+c1,0])
call setpos("'>",[0,l2,len2_-len2+c2,0])
normal! gv
endif
endfunction
vnoremap <silent> <C-/> :call VComment()<cr>
" vmap <C-7/> <Plug>NERDCommenterToggle<CR>gv
" function! IComment()
" let f7irstLine = line("'<")
" let lastLine = line("'>")
" let theLine = getline('.')
" if ( firstLine ==# lastLine ) && ( theLine =~ "^[ \t]*$" )
" call feedkeys("\<Plug>NERDCommenterToggle$a")
" else
" call feedkeys("\<PLUG>NERDCommenterToggle")
" call feedkeys("gi")
" endif
" endfunction
" function! NERDComment(mode, type) range
function! IComment()
let l0=line('.')
let c0=col('.')
let theLine = getline('.')
let len0=len(theLine)
if ( theLine =~ "^[ \t]*$" )
exe "silent normal! :call NERDComment('n', 'Toggle')\<CR>"
startinsert
normal! $
else
exe "silent normal! ^:call NERDComment('n', 'Toggle')\<CR>"
let len1=len(getline('.'))
startinsert
call cursor(l0,len1-len0+c0)
endif
endfunction
function! AtLineEnd()
return col('.')==#(len(getline('.'))+1)
endfunction
inoremap <expr> <silent> <C-/> AtLineEnd() && (! EmptyLine()) ?
\ "\<esc>:call NERDComment('n', 'Toggle')\<cr>$a" :
\ "\<space>\<bs>\<c-o>:call IComment()\<cr>"
" imap <C-/> <ESC><Plug>NERDCommenterToggle$a
" -----------------------------------------------------------------
let NERDSpaceDelims=1 " 让注释符与语句之间留一个空格
let NERDCompactSexyComs=1 " 多行注释时样子更好看
" let g:NERDCommentEmptyLines = 1 " 允许注释空白行
let g:NERDToggleCheckAllLines = 1 " 当所选非空行皆被注释,toggle才解注,否则toggle加注
"=========================================================================
" 搜索
"=========================================================================
" 搜索/关闭搜索高亮 ctrl+f
nnoremap <expr> <C-f> v:hlsearch ? ':silent! nohls<cr>' : ( (&modifiable) ? ':MarkClear<cr>i<c-o>:stopinsert<cr>/' : ':MarkClear<cr>/')
vnoremap <expr> <C-f> v:hlsearch ? '<esc>:silent! nohls<cr>v' : '"9y:MarkClear<cr><esc>/<c-r>9<cr>N'
inoremap <expr> <C-f> v:hlsearch ? '<c-o>:silent! nohls<cr>' : '<c-o>:MarkClear<cr><c-o>/'
" 放弃搜索,退出搜索框 ctrl+f
cnoremap <silent> <C-f> <c-u><bs><esc>:silent! nohls<cr>gi
" 大小写敏感 case
cnoremap <C-c> \C
" 大小写不敏感 non-sensitive
cnoremap <C-n> \c
" 整词匹配 大小写敏感
cnoremap <C-w> \<\><left><left>
" " 整词搜索 双击ctrl+f 进入搜索栏会显示'\<光标\>'
" nnoremap <C-f><C-f> :MarkClear<cr>i<c-o>:stopinsert<cr>/\<\><left><left>
" vnoremap <C-f><C-f> "9y:MarkClear<cr><esc>/\<\><left><left><c-r>9<cr>
" inoremap <C-f><C-f> <c-o>:MarkClear<cr><c-o>/\<\><left><left>
" 下一个 ctrl+enter
nnoremap ᜫ n
vnoremap ᜫ <esc>n
inoremap ᜫ <c-o>n
" 上一个 ctrl+shift+enter
nnoremap ᜬ N
vnoremap ᜬ <esc>N
inoremap ᜬ <c-o>N
" " 关闭搜索的高亮 shift+ctrl+f
" nnoremap <silent> ᜮ :silent! nohls<cr>
" vnoremap <silent> ᜮ <esc>:silent! nohls<cr>v
" inoremap <silent> ᜮ <c-o>:silent! nohls<cr>
" " 放弃搜索,退出搜索框 shift+ctrl+f
" cnoremap <silent> ᜮ <c-u><bs><esc>:silent! nohls<cr>gi
" =========================================================================
" far.vim 告诉全局搜索与替换
if PlugLoaded('far.vim')
set lazyredraw
set regexpengine=1
let g:far#source='rgnvim'
let g:far#ignore_files=['~/.vim/farignore']
let g:far#auto_preview_on_start=0
" let g:far#auto_preview=0
let g:far#enable_undo=1
let g:far#debug = 1
let g:far#show_prompt_key=1
" let g:far#prompt_mapping={
" \ 'quit' : { 'key' : '<esc>', 'prompt' : 'Esc' },
" \ 'regex' : { 'key' : '<c-x>', 'prompt' : '^X' },
" \ 'case_sensitive' : { 'key' : '<c-a>', 'prompt' : '^A' },
" \ 'word' : { 'key' : '<c-w>', 'prompt' : "^W" },
" \ 'substitute' : { 'key' : '<c-f>', 'prompt' : '^F' },
" \ }
let g:far#mode_open = { "regex" : 0, "case_sensitive" : 1, "word" : 0, "substitute": 0 }
let g:far#mapping = {
\ 'stoggle_expand' : "ᜂ",
\ 'stoggle_expand_all' : "ᜱ",
\ 'toggle_expand' : "≠",
\ 'toggle_expand_all' : "±",
\ 'stoggle_exclude' : "t",
\ 'toggle_exclude' : "f",
\ 'stoggle_exclude_all' : "T",
\ 'toggle_exclude_all' : "F",
\ 'open_preview' : "p",
\ 'close_preview' : "P",
\ 'jump_to_source' : "<cr>",
\ "preview_scroll_up" : "<PageUp>",
\ "preview_scroll_down" : "<PageDown>",
\ }
" alt+f: find
nnoremap <silent> ƒ :Farf<cr>
vnoremap <silent> ƒ :Farf<cr>
inoremap <silent> ƒ <c-o>:Farf<cr>
" nnoremap ƒ :F<space>
" vnoremap ƒ :F<space>*<space>
" inoremap ƒ <c-o>:F<space>
"
" shift+alt+f: replace
nnoremap <silent> Ï :Farr<cr>
vnoremap <silent> Ï :Farr<cr>
inoremap <silent> Ï <c-o>:Farr<cr>
" 关闭正则表达式: alt+r
" cnoremap ® \V
" let g:far#default_mappings=0
" 在far.vim窗口内的操作: `:h far-mappings`
" ctrl+= 展开/收起光标下的匹配项
" nnoremap <buffer><silent> ᜂ :call g:far#change_collapse_under_cursor(-1)<cr>
" " shift+ctrl+= 所有匹配项 展开/收起
" nnoremap <buffer><silent> ᜱ :call g:far#change_collapse_all(-1)<cr>
else
" ------------------------------------------------------------------------
" 目录下搜索
" vimgrep /匹配模式/[g][j] 要搜索的文件/范围
" g:表示是否把每一行的多个匹配结果都加入
" j:表示是否搜索完后定位到第一个匹配位置
" vimgrep /pattern/ % 在当前打开文件中查找
" vimgrep /pattern/ * 在当前目录下查找所有
" vimgrep /pattern/ ** 在当前目录及子目录下查找所有
" vimgrep /pattern/ *.c 查找当前目录下所有.c文件
" vimgrep /pattern/ **/* 只查找子目录
" :copen 显示所有搜索结果
" alt+f
nnoremap <plug>(VimGrep) :vimgrep //g ** \|"HELP\| * : under now dir\| ** : under now dir and subdirs\| *.c : .c files "\|<home><right><right><right><right><right><right><right><right><right>
nmap ƒ <plug>(VimGrep)
vmap ƒ <esc><plug>(VimGrep)
imap ƒ <c-o><plug>(VimGrep)
" shift+alt+f 打开搜索列表
" 左键双击/回车即可在当前窗口显示此文件,光标进入该窗口
" 再要将光标回到搜索列表,可以鼠标点击进入下方列表窗口,
" 或ctrl+alt+down,或
" shift+alt+f
" alt+shift+f 关闭列表窗口
nnoremap <silent> Ï :copen<cr>
vnoremap <silent> Ï <esc>:copen<cr>
inoremap <silent> Ï <c-o>:copen<cr>
" alt+enter 下一个
fun! CNext()
" 支持循环
try
cnext
catch /E553/
crewind
endtry
endf
nnoremap <silent> ᜯ :call CNext()<cr>
vnoremap <silent> ᜯ <esc>:call CNext()<cr>
inoremap <silent> ᜯ <c-o>:call CNext()<cr>
" shift+alt+enter 上一个
fun! CPrevious()
" 支持循环
try
cprevious
catch /E553/
clast
endtry
endf
nnoremap <silent> ᜰ :call CPrevious()<cr>
vnoremap <silent> ᜰ <esc>:call CPrevious()<cr>
inoremap <silent> ᜰ <c-o>:call CPrevious()<cr>
endif
" =========================================================================
if PlugLoaded('ctrlsf.vim')
" CtrlSF 目录下搜文件内容,高速
" double alt+f 开始搜索
nnoremap ƒƒ :CtrlSF<space>
vnoremap ƒƒ <esc>:CtrlSF<space>
inoremap ƒƒ <c-o>:CtrlSF<space>
" double shift+alt+f 显示之前的搜索栏/终止搜索并关闭搜索栏
nnoremap ÏÏ :CtrlSFToggle<cr>
vnoremap ÏÏ <esc>:CtrlSFToggle<cr>
inoremap ÏÏ <c-o>:CtrlSFToggle<cr>
" 在搜索结果栏中的快捷键
" 下一条:alt+enter
" 上一条:shift+alt+enter
"
" 在左侧窗口打开, 光标移过去: o, ctrl+o
" 在左侧窗口打开, 光标还在ctrlsf窗口中: O
" 打开到新tab, 光标过去:t
" 打开到新tab, 光标还在CtrlSf窗口中: T
" 打开到左侧窗口竖分屏, 光标移过去:alt+|
" 打开到左侧窗口横分屏, 光标移过去:shift+alt+|
"
" 打开到左侧预览窗口, 光标不移过去: p, 回车, 左鼠标双击
" 打开到左侧预览窗口, 光标移过去(. 进入insert模式): P
" focus在预览窗口, 关闭预览窗口, 光标回到ctrlSF窗口, 左侧窗口恢复原状: q, alt+w, ctrl+w
" 关闭ctrlsf窗口:q alt+w, ctrl+w
"
" ctrlsf窗口 的位置切换 在下方显示位置列表 <-> 在右侧显示附件全文: M
" ctrlsf窗口下方显示一个匹配的位置列表: s (这个没啥用)
" 在ctrlsf窗口内, 终止搜索: ctrl+c
let g:ctrlsf_mapping= {
\ "open" : ["o", "<c-o>"],
\ "openb" : "O",
\ "split" : "»",
\ "vsplit" : "«",
\ "tab" : "t",
\ "tabb" : "T",
\ "popen" : [ "p", "<CR>", "<c-m>", "<2-LeftMouse>" ],
\ "popenf" : "P",
\ "pquit" : "q",
\ "quit" : "q",
\ "next" : '<A-CR>',
\ "prev" : "ᜰ",
\ "loclist" : "s",
\ "chgmode" : "M",
\ "stop" : "<C-C>",
\ }
" 默认用normal(有上下文)型搜索结果栏,而非compact(无上下文)
let g:ctrlsf_default_view_mode = 'normal'
" noraml型搜索结果栏放在右侧
let g:ctrlsf_position = 'right'
" 任何时候 开了一个搜索结果 也不关闭窗口
let g:ctrlsf_auto_close = {
\ "normal" : 0,
\ "compact": 0
\}
" 当1000ms以内搜完 则自动将focus到搜索结果栏;
" 否则在搜索进行时用户可以正常编辑文件(这叫做异步搜索)
let g:ctrlsf_auto_focus = {
\ "at": "done",
\ "duration_less_than": 1000
\ }
endif
" ------------------------------------------------------------------------
" 同词高亮
" 双击选中一个词,高亮出全部相同的整词
noremap <plug>(2LEFTMOUSE) <2-leftMouse>
map <silent> <2-leftmouse> 1<Leader>m<plug>(2LEFTMOUSE)
imap <silent> <2-leftmouse> <c-o>1<Leader>m<c-o><plug>(2LEFTMOUSE)
" alt+l 选中一个词/放弃选中一个词
nnoremap ¬ viw
vnoremap ¬ <esc>viw
inoremap ¬ <c-o>viw
" 单击退出同词高亮
nnoremap <silent> <leftMouse> :silent MarkClear<cr><leftMouse>
vnoremap <silent> <leftMouse> <esc>:silent MarkClear<cr><leftMouse>
inoremap <silent> <leftMouse> <c-o>:silent MarkClear<cr><leftMouse>
" 同词高亮使用 :hi Search 返回的颜色
function! s:GetColor(color_type)
exec 'redir => result | silent! hi '.a:color_type.' | redir END'
let result=substitute(result, '\n' , '' , 'g')
let result=substitute(result, a:color_type.'\s\+xxx\s\+', '','g')
let result=substitute(result, '\s\+', "', '", 'g')
let result=substitute(result, '=', "':'", 'g')
let result="{'". result . "'}"
return result
endfunction
" 更换mark.vim (插件)的默认色表
exec "let g:mwPalettes={'mypalette': [".s:GetColor('Search')."]}"
let g:mwDefaultHighlightingPalette = 'mypalette'
if PlugLoaded('vim-multiple-cursors')
"=========================================================================
" 多光标
" Plug 'hyliang96/vim-multiple-cursors'
"=========================================================================
" 快捷键 mc:multiple cursor
" ------------------------------------------------------------------------
" 始模式 快捷键 末模式 功能
" ------------------------------------------------------------------------
" n <C-d> mc-v 选光标所在整词,之后<C-d>,<C-p>,<C-q>皆选整词
" v <C-d> mc-v 选下一相同文本(不必整词),之后<C-d>,<C-p>,<C-q>皆选文本(不必整词)
" n <S-d> mc-v 选光标所在整词,及全文诸相同整词
" v <S-d> mc-v 选全文诸文本(不必整词)之同被选者
" mc-v <C-d> mc-v 选下一个
" mc-v <C-q> mc-v 跳过这一个
" mc-v <C-p> mc-v 前一个
" v(选中多行) <C-d> mc-n 选中区起始光标之列,在诸行插入光标
" -----------------------------------------------------------------------
" 关系图 后 前插入光标
"
" v多行--<C-d> --- 插入多光标--> mc-n --a、i--\
" v↑↓v >→ mc-i -- <esc> --> n
" v --<C-d>、<S-d> --选文本--> mc-v --A、I--/
" n --<C-d>、<S-d> --选整词/ 后 前插入光标
" 选下一个 所有
let g:multi_cursor_use_default_mapping=0
let g:multi_cursor_start_word_key = '<C-d>'
" 在n模式,选择光所在整词,及全文与之相同的文本(不必整词)
let g:multi_cursor_select_all_word_key = 'ᜤ' " shift+ctrl+d
" let g:multi_cursor_start_key = '∂' " alt+d
" " 按g松后,按立即按ctrl+d
" let g:multi_cursor_select_all_key = 'Î' " shift+alt+d
" " 按g松后,立即按+alt+d
" "
" 增选下一与之同的文本
let g:multi_cursor_next_key = '<C-d>'
let g:multi_cursor_prev_key = '<C-p>'
let g:multi_cursor_skip_key = '<C-q>'
let g:multi_cursor_quit_key = '<esc>'
" '≈' " alt+x
imap <silent> <c-d> <c-o>:stopinsert<cr><c-d>
imap <silent> ᜤ <c-o>:stopinsert<cr>ᜤ
" let g:multi_cursor_normal_maps={'ᜤ':1}
" let g:multi_cursor_visual_maps={'ᜤ':1}
endif
if PlugLoaded('vim-visual-multi')
"=========================================================================
" Plug 'mg979/vim-visual-multi'
" 高性能多光标、多选区、正则表达式搜索、按住Shift+方向键选择
let g:VM_maps = {}
" ------------------------------------------------------------------------
" 进入多光标模式:
" " v模式下, <esc>alt+a 清空多光标选区,再将当前区域加入多光标选区
" let g:VM_maps["Visual All"] = '<esc>å'
" v模式下,alt+a:将选中区域加入多光标选区
" i/n 模式下,alt+a,光标所在区加一个多光标
let g:VM_maps["Visual Add"] = '<plug>(AddRegion)'
let g:VM_maps["Add Cursor At Pos"] = '<plug>(AddCursor)'
vmap å <plug>(AddRegion)
nmap å <plug>(AddCursor)
imap å <esc><plug>(AddCursor)
" -------------------------------------------------------------------------
" 使用说明
" -------------------------------------------------------------------------
" 如何进入多选模式(多光标v模式)
"
" i/n模式下
" ctrl+d,选中光标所在词,继续按ctrl+d以增选整词
" q: 跳过一个
" Q: 清除这个光标,返回上一个
" shift+ctrl+d 选中所有与光标所在词相同的整词
"
" v模式下
" ctrl+d,增选与选区相同的文字,不必是整词
" shift+ctrl+d,选中所有与选区相同的文字,不必q是整词
"<Plug>(VM-LazyNoh) ctrl+l,选中多行,将其转为每行一个光标
"
" 多光标v模式下
" 鼠标选中一个区域,alt+a,添加到多光标选区
" ------------------------------------------------------------------------
" 如何进入多位置模式(多光标v模式)
" i/n 模式下,alt+a,添加一个光标位置,形如宽度为1的选区
" 在多光标n模式下,鼠标点击位置,alt+a,继续添加一个光标位置
"
" -------------------------------------------------------------------------
" 在多光标n/v模式下:
" S-Left/Right:左右移动选区边界
" o 切换在选区左还是右边界
" 移动边:界h左,l右; j下,k上;0行首,^行非空之首,$行尾
" p: 用剪切板替换各选区
" c:清空当前各选区,加入插入模式
" a: 选区后进入插入模式
" i: 选区前进入插入模式
" <esc>/<c-i>: 退出多光标i模式
" <esc>/<c-'>: 退出多光标v模式
" <esc>: 在多光标n/v模式,按它退出多光标模式
" ------------------------------------------------------------------------
let g:VM_maps['Find Under'] = '<plug>(FindUnder)' " 增选下一个与本词相同的词
let g:VM_maps['Find Subword Under'] = '<plug>(FindUnder)' " 增选下一个与选区相同的文字
let g:VM_maps["Select All"] = '<plug>(SelectAll)' " 全选
let g:VM_maps["Remove Region"] = 'Q' " 清除这个光标
let g:VM_maps['Skip Region'] = 'q' " 跳过一个
" shift+ctrl+d: ᜤ
" nmap <c-d> <plug>(VM-Find-Under)
nmap <c-d> <plug>(FindUnder)
nmap ᜤ <plug>(SelectAll)
vmap <c-d> :<c-u>stopinsert<cr>gv<plug>(FindUnder)
vmap ᜤ :<c-u>stopinsert<cr>gv<plug>(FindUnder)<plug>(SelectAll)
imap <c-d> <esc><plug>(FindUnder)
imap ᜤ <esc><plug>(SelectAll)
" ctrl+l: 多行选择转多行光标:多行选中(v模式),选区变为多行光标的insert模式,光标都在选区开头字符所在列
" FIXME 选区中有宽字符时会出错
let g:VM_maps["Visual Cursors"] = '<plug>(MultiLineCurosr)'
" v模式下,ctrl+l: 单行为选中整行,多行则转为多行光标
fun! VCtrlL() range
if line("'<") < line("'>")
call feedkeys("gv\<plug>(MultiLineCurosr)")
else
call feedkeys("gv\<plug>(SelectOneLine)")
endif
endf
vmap <c-l> :call VCtrlL()<cr>