本人是生信工程师,主要使用的语言是 python, R, perl, shell,经常要ssh到远程服务器上写代码,因此学习了vim,后来发现了spf13-vim:steve francia's vim distribution,大大提高了写代码的效率。但是,原配置仍然有很多插件和配置不符合我的需要,因此,fork后进行了大量的修改.请访问leoatchina的vim配置文件.由于本人水平所限,一定有很多错误和bug,望各位指正. 注意使本配置文件后可能会影响vim运行流畅度.
掌握vim的大部分操作,了解 leader, map, hjkl, d, w, s, i, u, :, \等操作命令
各配置文件执行次序
.vimrc.before # 参数配置文件.vimrc.before.local.vimrc.bundles # 插件管理文件.vimrc.bundles.local.vimrc # 最主要的配置文件,配色、快捷键、显示方式等参数都在这里设置.vimrc.local安装本配置 需要 Git 1.7+ 和 Vim 7.3+(编译时加入对lua和python的支持),部分插件如 Nvim-R, AsyncRun,需要Vim8.0 如果要安装neocomplete, 需要vim with lua.
git clone https://github.com/leoatchina/spf13-vim-leoatchina.git cd spf13-vim-leoatchina bash bootstrap.sh git clone https://github.com/leoatchina/spf13-vim-leoatchina.git cd spf13-vim-leoatchina 点击install.cmd vim +BundleUpdate 或者在vim里直接 :BundleUpdate
>, <移动文字不会取消选择我在spf13的基础上,做了一些微小的工作
~/.vimrc.before.local里开启~/.vimrc.before.local里进行配置,如我加入了对 youcompletme的配置,也可以使用 neocomplte和 neocomplcache~/.vimrc.before.local,可以看到有对 python, R, markdown的支持 let g:spf13_bundle_groups=['general', 'programming', 'python', 'youcompleteme','php', 'javascript', 'html','R','markdown','material']<leader>键改为空格键,这个在键盘上最大的按键就有了更强的作用; <localleader>改为 \, \在R编写调试时使用率比较高~作为进入 ex模式的快捷键, Q键map为 <Nop>F1: 为 :h,方便启动帮助F2: 打开关闭代码折叠 或 <leader>wdF3: 打开关闭换行 或 <leader>fdF4: 打开关闭搜索高亮 或 <leader>hlF5: 运行脚本(python、perl、c等)或 <leader>R; Shift+F5:运行脚本并记录时间; <leader>+F5: AsyncRunF11: 全屏切换,如果是windows下的gvim,要把本目录下的 gvim_fullscreen.dll放到 gvim的安装目录下F12: 切换paste模式,或者 <leader>tg<leader>fc:fixed confict markers<leader>fw:对当前光标下文字进行搜索<leader>mk:markdown调用chrome生成markdown previewVisual模式下按 .为退出 Visual模式 nnoremap <silent>- : tabprevious<CR> nnoremap <silent>= : tabnext<CR> nnoremap <leader>tf : tabfirst<CR> nnoremap <Leader>tl : tablast<CR> nnoremap <leader>tn : tabnew<CR> nnoremap <Leader>ts : tabs<CR> nnoremap <Leader>tp : tab split<CR> nnoremap <Leader>te : tabe<SPACE> nnoremap <Leader>tm : tabm<SPACE> nnoremap <silent>_ : tabm -1<CR> nnoremap <silent>+ : tabm +1<CR>Ctrl+e移到一行的结尾; Ctrl+y移到一行的开头Ctrl+m括号之间跳转<leader>w保存当前文件; <leader>W保存所有文件<leader>q关闭当然文件; Q为 :qa,不过给你反悔的机会不直接按下回车 " 设置快捷键将选中文本块复制至系统剪贴板 vnoremap <leader>y "+y nnoremap <leader>y "+y nnoremap <leader>Y "+yg nnoremap <leader>yy "+yy " Yank from the cursor to the end of the line nnoremap Y y$ " p and P for paste nnoremap <leader>p "+p nnoremap <leader>P "+P vnoremap <leader>p "+p vnoremap <leader>P "+P " buffer switch nnoremap <leader>bn :bn<CR> nnoremap <leader>bp :bp<CR> " 定义快捷键保存当前窗口内容 nmap <Leader>w :w<CR> nmap <Leader>W :wq!<CR> " 定义快捷键保存所有窗口内容并退出 vim nmap <Leader>WQ :wa<CR>:q<CR> " 定义快捷键关闭当前窗口 nmap <Leader>q :q<CR> " 不做任何保存,直接退出 vim nmap <Leader>Q :qa!<CR> " 设置分割页面 nmap <Leader>- :split<Space> nmap <leader>\ :vsplit<Space> nmap <leader>= <C-W>= "设置垂直高度减增 nmap <Leader>{ :resize -3<CR> nmap <Leader>} :resize +3<CR> "设置水平宽度减增 nmap <Leader>[ :vertical resize -3<CR> nmap <Leader>] :vertical resize +3<CR> "至左方的子窗口 nnoremap <Leader>H <C-W>H "至右方的子窗口 nnoremap <Leader>L <C-W>L "至上方的子窗口 nnoremap <Leader>K <C-W>K "至下方的子窗口 nnoremap <Leader>J <C-W>J " Visual shifting (does not exit Visual mode) vnoremap < <gv vnoremap > >gv " Ctrl-m for switch between brackets map <C-m> %spf13设计了一系列巧妙的 配置变量,在 .vimrc.before.local里写入配置变量后,可打开/关闭某些配置 如,关闭自动cd到某个目录
echo let g:spf13_no_autochdir = 1 >> ~/.vimrc.before.local在 ~/.vimrc.before文件里可以看到各个变量详细说明
强大的插件系统是spf13-vim的突出优点,通过这些插件,将原版的vim的功能作了极大的丰富。让界面更加美观,操作更加方便。在原有的基础上,我加入了很多自己用的插件和对配置文件进行了修改 spf13没有选用pathongen作为插件管理器,还是选用经典的vundle
这是我在mac下的iterm2终端下使用的主题,material配色,配合半透明效果看起来很酷炫。

但要求终端支持 True Color,如果不支持,效果会惨不忍睹。因此改成手动开启,方法:在 ~/.vimrc.before.local里的 g:spf13_bundle_groups列表里加入 material

经典主题,默认开启,给一张官方的图

还有三套内置配色方案 ir_black, molokai, peaksea,通过 :color命令开启
在侧边显示当前目录,Toggle快捷键为 Ctrl-N或者 <leader>nn

显示文档结构,在 python, vim里肯定有用,要求在系统里安装 ctags 用 Ctrl+Tor <leader>tt切换在测边显示文档结构.在bar窗口里按 F1调出帮助窗口

另一个显示文档结构的插件,和 TagBar逻辑不一样, python里肯定有用,其他语言我还没有测试出来。快捷键 <leader>vo打开 :Voom命令; <leader>vt为 :VoomTogglevoom状态切换

undotree顾名思义,增强版的回退插件,快捷键 <leader>u
漂亮的状态栏,能够显示很多状态。

ywvim中文输入法,直接在vim里内置,无意中发现要和fcitx配合使用否则会有bug,在 insert模式下通过 CTRL+@或 CTRL+\开启, CTRL+^进行配置. ;临时英文输入法;注意,默认只输入英文状态的标点,而且首选是 五笔; z临时拼音; ,.-=上下翻页;


默认开户对markdown语言的高亮支持,如 .vimrc.before.local里指定 markdown支持,按 <leadr>mk调用 chrome打开markdown预览,不过这个功能还要仔细测试过.
对git的支持,具体可以看官方说明,不过我就设置了快捷键 <leader>gi :Git<Space>,操作体验接近终端下输入 git命令
注释插件,神器,直接上官方的快捷键,最常用的是 <leader>c<space>
[count]<leader>cc |NERDComComment| Comment out the current line or text selected in visual mode.[count]<leader>cn |NERDComNestedComment| Same as
cc but forces nesting.[count]<leader>c<space> |NERDComToggleComment| Toggles the comment state of the selected line(s). If the topmost selected line is commented, all selected lines are uncommented and vice versa.[count]<leader>cm |NERDComMinimalComment| Comments the given lines using only one set of multipart delimiters.[count]<leader>ci |NERDComInvertComment| Toggles the comment state of the selected line(s) individually.[count]<leader>cs |NERDComSexyComment| Comments out the selected lines with a pretty block formatted layout.[count]<leader>cy |NERDComYankComment| Same as
cc except that the commented line(s) are yanked first.<leader>c$ |NERDComEOLComment| Comments the current line from the cursor to the end of line.<leader>cA |NERDComAppendComment| Adds comment delimiters to the end of line and goes into insert mode between them.<leader>ca |NERDComAltDelim| Switches to the alternative set of delimiters.[count]<leader>cl [count]<leader>cb |NERDComAlignedComment| Same as |NERDComComment| except that the delimiters are aligned down the left side ( <leader>cl) or both sides ( <leader>cb).[count]<leader>cu |NERDComUncommentLine| Uncomments the selected line(s).Ag是一个非常快的文件/文本搜索工具,通过 <leader>ag开遍文本搜索, <leader>af文件搜索

自动按特定的符号对齐,快捷键见 .vimrc里的配置文件 nmap <Leader>a& :Tabularize/&<CR> vmap <Leader>a& :Tabularize /&<CR> nmap <Leader>a= :Tabularize /^[^=]*\zs=<CR>vmap <Leader>a= :Tabularize /^[^=]*\zs=<CR> nmap <Leader>a=> :Tabularize /=><CR> vmap<Leader>a=> :Tabularize /=><CR> nmap <Leader>a: :Tabularize /:<CR> vmap <Leader>a::Tabularize /:<CR> nmap <Leader>a:: :Tabularize /:\zs<CR> vmap <Leader>a:: :Tabularize/:\zs<CR> nmap <Leader>a, :Tabularize /,<CR> vmap <Leader>a, :Tabularize /,<CR> nmap<Leader>a,, :Tabularize /,\zs<CR> vmap <Leader>a,, :Tabularize /,\zs<CR> nmap<Leader>a<Bar> :Tabularize /<Bar><CR> vmap <Leader>a<Bar> :Tabularize /<Bar><CR>
sessionmanager, <leader>sl显示session列表; <leader>ss保存session; <leader>sc关闭session
杀手级插件,引用网上的一段话对它的介绍
在 VIM 世界里,有人是分窗口编辑文件的忠实拥护者,有人则是多文件 tab 页的死忠骨灰粉。但无论哪种人, 在一些大项目内进行编辑工作时,如果要快速打开 './lib/foo/bar/comm/base_utils.py' 这类藏在大山深处的文件,都需像剥粽子一样,一层一层往下找,让人头疼。 ctrlp.vim 则完美帮你解决了这个痛点,当你想打开某个文件时,只要按下 Ctrl + p 快捷键,输入文件名。 所有和这个文件名匹配的文件都会被按照优先级列出来,按下 enter 或者 Ctrl + t 就可以在当前 buffer 或者新 tab 页打开你要的文件了。
网上找来的图(动画哦)

ctrl+p启动插件, <leader>fu启动funksky函数查询功能,在启动后,用 Ctrl+f, Ctrl+b在不同模式中切换. 在文件列表中, Ctrl+k/j或者方向键向上/下选择文件, t在新标签里打开文件.其他快捷键见ctrlp中文介绍
python用的插件,具有语法检查,调试等功能. F9: python语法检查, S+F9切换语法是否检查. <leader>R:运行脚本; <leader>T:track_point toggle
给一段文字加上括号的插件,下面说明文字引用自vim中的杀手级别的插件:surround
Old text Command New text "Hello *world!" ds" Hello world! [123+4*56]/2 cs]) (123+456)/2 "Look ma, I'm *HTML!" cs"<q> <q>Look ma, I'm HTML!</q> if *x>3 { ysW( if ( x>3 ) { my $str = *whee!; vlllls' my $str = 'whee!'; <div>Yo!*</div> dst Yo! <div>Yo!*</div> cst<p> <p>Yo!</p>如上面代码块所示,添加替换时使用后半括号)]},添加的括号和内容间就没有空格(如第2个示例),反之会在内容前后添加一个空格(如第4个实例)。第6个示例中的t代表一对HTML或者xml tag。其他表示范围的符号:w代表word, W代表WORD(被空格分开的连续的字符窜),p代表paragraph。
命令列表
Normal mode ----------- ds - delete a surrounding cs - change a surrounding ys - add a surrounding yS - add a surrounding and place the surrounded text on a new line + indent it yss - add a surrounding to the whole line ySs - add a surrounding to the whole line, place it on a new line + indent it ySS - same as ySs Visual mode ----------- s - in visual mode, add a surrounding S - in visual mode, add a surrounding but place text on new line + indent it Insert mode "不建议使用 ----------- <CTRL-s> - in insert mode, add a surrounding <CTRL-s><CTRL-s> - in insert mode, add a new line + surrounding + indent <CTRL-g>s - same as <CTRL-s> <CTRL-g>S - same as <CTRL-s><CTRL-s>The most feature complete and up to date PHP Integration for Vim with proper support for PHP 5.3+ including latest syntax, functions, better fold support, etc.
PIV provides:

支持R语言的插件,需要 Vim8.0+并在 .vimrc.before.local里加入 R.通过 <leader>rr激活界面, <leader>rq退出R程序


快捷键极多,请自行 :h nvim-r查询
又一个杀手级别的插件

<leader><leader>w和 <leader><leader>b<leader><leader>s,然后输入要搜索的字母<leader><leader>再 hjkl不解释<leader><leader>.<leader><leader>f和 <leader><leader>t,不过不建议使用~/.vimrc.before.local里加入 youcomplteme或 neocomplte或 neocomplcache来激活安装。Tab、 Shift-Tab为 向下, 向上翻页, ctrl-n/p也能进行翻页. enter或 Ctrl+k激活补全。 ctrl+l显示各种实例可能Ctrl+f跳转到下一个待补全处, Ctrl+b中转到上一个待补全处。cd ~/.vim/bundle/YouCompleteMe python2 install.py#可能仅支持python等不需要编译的语言neocomplete需要 lua的支持