插件
1.vim-plug
插件管理
junegunn/vim-plug: ? Minimalist Vim Plugin Manager
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
- PlugInstall [name ...]
- PlugUpdate [name ...]
- PlugClean[!]
- PlugUpgrade: Upgrade vim-plug itself
- PlugStatus: Check the status of plugins
- PlugDiff: Examine changes from the previous update and the pending changes
- PlugSnapshot[!] [output path]: Generate script for restoring the current snapshot of the plugins
vim-plug 安装失败_vimplus安装失败_云梦谭的博客-CSDN博客
$ diff plug.vim plug.vim.bak
778c778
< let fmt = get(g:, 'plug_url_format', 'https://git::@ghproxy.com/https://github.com/%s.git')
---
> let fmt = get(g:, 'plug_url_format', 'https://git::@github.com/%s.git')
1174c1174
< \ '^https://git::@ghproxy.com\.com', 'https://ghproxy.com/https://github.com', '')
---
> \ '^https://git::@github\.com', 'https://github.com', '')
2.NERDTree
文件浏览器
preservim/nerdtree: A tree explorer plugin for vim.
nnoremap <leader>n :NERDTreeFocus<CR>
nnoremap <C-n> :NERDTree<CR>
nnoremap <C-t> :NERDTreeToggle<CR>
nnoremap <C-f> :NERDTreeFind<CR>
3.vim-devicons
用于支持Nerd Fonts, Nerd Fonts需要额外安装
ryanoasis/vim-devicons: Adds file type icons to Vim plugins such as: NERDTree, vim-airline, CtrlP, unite, Denite, lightline, vim-startify and many more
set encoding=UTF-8
call plug#begin()
Plug 'ryanoasis/vim-devicons'
call plug#end()
4.ctags
vim+ctags+cscope+Taglist+Nerdtree打造成sourceinsight - 知乎
ctags文件只能查看函数、类或变量的定义,而没有被调用信息。如果要知道一个函数在什么地方被使用,需要使用cscope工具。
添加的tags最好是source code的索引,对于头文件索引没有效果。
sudo apt install universal-ctags
# 生成ctag文件
ctags -R --c++-kinds=+p --fields=+iaS --extras=+q
ctags的选项:
-R表示递归创建,也就包括源代码根目录(当前目录)下的所有子目录;
--c++-kinds=+ps是为c/c+语言添加函数原型信息;
--fields=+iaS是为标签添加继承信息(inheritance),访问控制信息(access)和函数特征(Signature)如参数表或原型等;
--extra=+q是为类成员添加标签;
当用户在当前目录中运行vi时,会自动载入此tags文件。假如你想让你当前目录文件中的函数名在其他目录中打开vim时也能被定位到的话,那么可以把当前目录的tags文件路径添加到.vimrc中: set tags+=/home/ubuntu/code/tags
5.cscope
sudo apt install cscope
cscope -Rbkq
cscope的选项:
-R: 在生成索引文件时,搜索子目录树中的代码
-b: 只生成索引文件,不进入cscope的界面
-q: 生成cscope.in.out和cscope.po.out文件,加快cscope的索引速度
-k: 在生成索引文件时,不搜索/usr/include目录
-i: 如果保存文件列表的文件名不是cscope.files时,需要加此选项告诉cscope到哪儿去找源文件列表。可以使用“-”,表示由标准输入获得文件列表。
-I dir: 在-I选项指出的目录中查找头文件
-u: 扫描所有文件,重新生成交叉索引文件
-C: 在搜索时忽略大小写
-P path: 在以相对路径表示的文件前加上的path,这样,你不用切换到你数据库文件所在的目录也可以使用它了。
生成.out文件之后,我们需要在当前用户的用户目录中的.vimrc文件中把.out数据库的路径配置进去,假如不配置的话,cscope无法查找.out所在目录文件中的函数等,使用cs add命令添加.out的路径,即在~/.vimrc文件中添加下面这些内容即可: cs add /home/ubuntu/linux-4.12.1/linux/cscope.out
6.taglist
vim-scripts/taglist.vim: Source code browser (supports C/C++, java, perl, python, tcl, sql, php, etc)
yegappan/taglist: Source code browser plugin for Vim
Taglist其实是一个vim的插件,能将当前vim打开的文件中函数名、变量名等在一个窗口中列出来,并支持通过列出的函数名实现跳转。
"Tlist 的快捷键
map <F2> :Tlist <CR>
7.winmanager
anscoral/winmanager.vim: winmanager : A windows style IDE for Vim
let g:winManagerWindowLayout='FileExplorer|TagList'
nmap wm :WMToggle<cr>