This plugin aim to simple the usage of ctags and gtags for Vim.
It is used for generate and auto load exists tags.
This plugin contains two Vim scripts.
gen_ctags.vim
Manage ctags db for project<br/>
The generated ctags DB will be placed under `~/.cache/tags_dir/[foldername]`<br/>
gen_ctags.vim will detect git root and use it as project root path.
gen_gtags.vim
[GNU Global](https://www.gnu.org/software/global/) use gtags-cscope with if_cscope interface in Vim.<br/>
[GNU Global](https://www.gnu.org/software/global/) will generate **GTAGS**, **GRTAGS** and **GPATH** under the project folder.<br/>
gen_gtags.vim will detect git root then generate GTAGS under the git root.
Generate ctags and update gtags will run in background.
If vimproc was enabled gen_tags.vim will use it.
It's good for Microsoft windows, because the CMD window is boring, even the command is running in background.
GNU global(aka gtags) is more powerful than ctags, which support definition, reference, calling, called, include, string and etc, but ctags only support definition.
As we can use GNU global why did I still support ctags in this plugin?
That's because GNU global only support 6 languages (C, C++, Yacc, Java, PHP4 and assembly) natively.
ctags can support more languages(41 showed on the website).
Actually global can support more languages with Pygments plugin parser, for more details please refer PLUGIN_HOWTO.pygments
in global document.
-
Neobundle
Add
NeoBundle 'jsfaint/gen_tags.vim'
to your vimrc
Then launchvim
and run:NeobundleCheck
To install from command line:
vim +PluginInstall +qall
-
Vundle
Add
Plugin 'jsfaint/gen_tags.vim'
to your vimrc
Then launchvim
and run:PluginInstall
To install from command line:
vim +PluginInstall +qall
-
Traditional method
Put two Vim script(
gen_tags.vim
,gen_gtags.vim
) underplugin
directory.
-
:GenCtags
Generate ctags database
-
:GenAll
Generate ctags and extend database
-
:GenExt
Generate extend ctags for third-party library
-
:EditExt
Edit an extend configuration file for this project, use for add third-party library ctags database
e.g.: For libpcap under
e:\src\libpcap-1.3.0
add the following content toext.conf
e:/src/libpcap-1.3.0
-
:ClearCtags
:ClearCtags Remove tags files. :ClearCtags! Remove tags files, ext.conf and the folder.
GTAGS support the third-party library by set an environment variable GTAGSLIBPATH
But you can take a more straightforward way to do the same thing, by create a symbol link of the library
-
Linux/OS X
ln -s /usr/include/ .
-
Windows
mklink /J include C:\TDM-GCC-32\include
-
:GenGTAGS
Generate GTAGS
-
:ClearGTAGS
Clear GTAGS files
ctrl+]
is the default mapping support by Vim for definition
The following mapping is set for GTAGS find function which use cscope interface (if_cscope
).
Ctrl+\ c Find functions calling this function
Ctrl+\ d Find functions called by this function
Ctrl+\ e Find this egrep pattern
Ctrl+\ f Find this file
Ctrl+\ g Find this definition
Ctrl+\ i Find files #including this file
Ctrl+\ s Find this C symbol
Ctrl+\ t Find this text string
g:ctags_opts
Set ctags options. The -R
is set by default, so there is no need to add -R
in g:ctags_opts
.
The default g:ctags_opts
is '', you need to set it in your vimrc 😄
g:gtags_split
Set gtags find display behavior. The default g:gtags_split
is ''.
'' means don't split the display.
'h' means horizontal splitting.
'v' means vertical splitting.
Thanks for reading :)
If you like this plugin, please star it on github!
And one more thing, bug reports and pull-requests are greatly appreciated :)