Plugins of VIM
coc.nvim
在VIM中查看coc.nvim的help文档
:h coc-nvim
设定存放extension,config等数据的目录
设定config home和data home(extension目录)
config home 变量:coc_config_home
data home 变量:coc_data_home
""Configure the directory which will be used to look for
""user's coc-settings.json, default:
"" Windows: ~/AppData/Local/nvim
"" Other: ~/.config/nvim`
let g:coc_config_home = 'D:/procs/VimVersion9/vimfiles/coc_nvim_files/config_home'
""Configure the directory which will be used to for data
""files(extensions, mru and so on), default:
""Windows: ~/AppData/Local/coc
""Other: ~/.config/coc`
let g:coc_data_home = 'D:/procs/VimVersion9/vimfiles/coc_nvim_files/data_home'
打开config文件
:CocConfig
该命令会打开一个名为$coc_config_home/coc-settings.json的目录,其中$coc_config_home见上面的设定,如果没有修改,默认在windows下是~/AppData/Local/coc。
coc-snippets
在安装完毕coc-snippets之后,就可以使用如下命令来编辑添加自定义的coc-snippets
:CocCommand snippets.editSnippets
用该命令可以打开在$coc_data_home/ultisnips/<type-name>.snippets文件,其中<type-name>表示和当前文件类型相同的类型名称,比如当前打开的是cpp文件,那么:CocCommand snippets.editSnippets就会打开一个名字叫做$coc_data_home/ultisnips/cpp.snippets的文件以供编辑。
自动补全
动补全默认是自动开启
末尾带有
~符号的是snippet format的补全,需要用Ctrl + N(或Ctrl + P)选定,然后使用Ctrl + Y来展开(expand)当snippet expand被激活时,可以使用
Ctrl + J和Ctrl + K来跳转到下一个或上一个占位符处(placeholder)。比如,如果选定并展开了for这个snippet,那么当前就会插入如下的一段代码for (init-statement; condition; inc-expression) { statements }
并且当前
init-statement会被选择并处于插入模式(insert mode),写完初始条件之后,就可以使用Ctrl + J跳转到下一处(condition)并继续书写。如果需要跳转到上一处,使用Ctrl + K。变量
g:coc_snippet_prev和g:coc_snippet_next可以用来调整跳转快捷键参考帮助文档中的
coc-snippets小节查看更多
vim-mark
GitHub link
Vim-script link
安装(注意,需要同时安装vim-ingo-library才能使用)
Plug 'inkarkat/vim-ingo-library'
Plug 'inkarkat/vim-mark'
vim中打开帮助文档
:h mark.txt
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!'; |
tagbar
安装(注意,需要同时安装ctags才能使用)
注意,’majutsushi/tagbar’似乎不再维护了
# Plug 'majutsushi/tagbar'
Plug 'preservim/tagbar'
根据preservim/tagbar说明,使用universal-ctags/ctags,下载页面是universal-ctags/ctags-win32,release page,下载完成后直接解压到一个目录即可,然后再vimrc中设置ctags路径
""" ------------------------------------------------------
""" tagbar
""" ------------------------------------------------------
function s:setup_tagbar()
nmap <F2> :TagbarToggle<CR>
""let g:tagbar_ctags_bin = '~/proc/ctags5.8/bin/ctags'
""let g:tagbar_ctags_bin = '/usr/bin/ctags'
let g:tagbar_ctags_bin = 'D:/procs/ctags59/ctags.exe'
let g:tagbar_width = 30
let g:tagbar_left = 1
" Set sort order to 0, it will list the tags in the
" order where they appear in the source file, other
" than alphabetic order
let g:tagbar_sort = 0
""map <F3> :Tagbar<CR>
endfunction " End of function s:setup_tagbar
air-line
切换buffer
let g:airline#extensions#tabline#buffer_idx_mode = 1
" Hotkey to loop around GUI tabs
" Next buffer tab
""nmap <TAB> :bNext<CR>
nmap <TAB> <Plug>AirlineSelectNextTab
" Previous buffer tab
""nmap <C-TAB> :bprevious<CR>
nmap <C-TAB> <Plug>AirlineSelectPrevTab
"" Switch to a specific numbered buffer
nmap <leader>1 <Plug>AirlineSelectTab1
nmap <leader>2 <Plug>AirlineSelectTab2
nmap <leader>3 <Plug>AirlineSelectTab3
nmap <leader>5 <Plug>AirlineSelectTab5
nmap <leader>6 <Plug>AirlineSelectTab6
nmap <leader>7 <Plug>AirlineSelectTab7
nmap <leader>8 <Plug>AirlineSelectTab8
nmap <leader>9 <Plug>AirlineSelectTab9
nmap <leader>0 <Plug>AirlineSelectTab0
注意<leader>一般会设定为,。