$ git clone https://github.com/universal-ctags/ctags.git
$ cd ctags
$ sudo apt install -y gcc make pkg-config autoconf automake python3-docutils \
libseccomp-dev libjansson-dev libyaml-dev libxml2-dev
$ ./autogen.sh
$ ./configure --prefix=/path/to/universal-ctags #安装路径, 自己根据需要更换
$ make -j
$ sudo make install
Place this in your .vimrc:
Plugin 'ludovicchabant/vim-gutentags'
… then run the following in Vim:
:source %
:PluginInstall
For Vundle version < 0.10.2, replace Plugin with Bundle above.
Place this in your .vimrc:
Plug 'ludovicchabant/vim-gutentags'
… then run the following in Vim:
:source %
:PlugInstall
Place this in your vimrc:
set tags=./.tags;,.tags
" gutentags 搜索工程目录的标志,碰到这些文件/目录名就停止向上一级目录递归
let g:gutentags_project_root = ['.root', '.svn', '.git', '.hg', '.project']
" 所生成的数据文件的名称
let g:gutentags_ctags_tagfile = '.tags'
" 将自动生成的 tags 文件全部放入 ~/.cache/tags 目录中,避免污染工程目录
let s:vim_tags = expand('~/.cache/tags')
let g:gutentags_cache_dir = s:vim_tags
" 配置 ctags 的参数
let g:gutentags_ctags_extra_args = ['--fields=+niazS', '--extra=+q']
let g:gutentags_ctags_extra_args += ['--c++-kinds=+px']
let g:gutentags_ctags_extra_args += ['--c-kinds=+px']
" 检测 ~/.cache/tags 不存在就新建
if !isdirectory(s:vim_tags)
silent! call mkdir(s:vim_tags, 'p')
endif
- run for single file:
$ ctags <filename>
- run for project:
$ ctags -R *