EasyTags is a fantastic plugin for Vim. It achieves two objectives that are related to each other: automatically index your source code and enhance the syntax highlighting of your source code. These two tasks are related because improving the syntax highlighting of code requires knowledge of what every word means in your code, which is what the tags provide. This adds another IDE-like feature to Vim.
- This plugin uses the Exuberant Ctags tool, so you will need to have it installed already.
Installing EasyTags requires installing two plugins using your favorite plugin manager:
vim-easytags. These can be obtained from these two links: https://github.com/xolox/vim-easytags and https://github.com/xolox/vim-misc
This plugin automatically generates tags for the currently open files using the
ctagstool. This is written to
~/.vimtags. The tags are generated automatically when you do not move the cursor for a few milliseconds. Vim generates the
CursorHoldwhen you pause typing and EasyTags uses this to do its work. Note that the tags are generated even if your file is not yet saved, since EasyTags is using the buffer, not the file.
This plugin also automatically highlights the tags it has indexed. Vim can only highlight the keywords of a language, not the new types or functions you define in it. EasyTags uses the index it has generated and highlights all the tags. So, you should see a lot more of your code in colors.
This plugin can be configured to read and update the
tagsfile of your project, instead of using
~/.vimtags. To do this, your Vim should be configured to walk back the directory hierarchy to pick the first
tagsfile it can find. Then EasyTags can be requested to use this tags file for updating, if it is found. I achieve this by adding these two lines to
" Let Vim walk up directory hierarchy from CWD to root looking for tags file set tags=tags;/ " Tell EasyTags to use the tags file found by Vim let g:easytags_dynamic_files = 1
- To generate tags only when a file is saved, add this to
let g:easytags_events = ['BufWritePost']
- To disable automatic highlighting of tags, add this to
let g:easytags_auto_highlight = 0
To explicitly ask EasyTags to index files, use the command
To explicitly ask EasyTags to highlight tags, use the command
Tried with: Vim 7.4 and Ubuntu 14.04