📅 2015-Mar-21 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ ctags, easytags, plugin, syntax highlighting, tags, vim ⬩ 📚 Archive
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-misc
and 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 ctags
tool. This is written to ~/.vimtags
. The tags are generated automatically when you do not move the cursor for a few milliseconds. Vim generates the CursorHold
when 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 tags
file 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 tags
file 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 .vimrc
:
" 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
.vimrc
:let g:easytags_events = ['BufWritePost']
.vimrc
:let g:easytags_auto_highlight = 0
To explicitly ask EasyTags to index files, use the command :UpdateTags
To explicitly ask EasyTags to highlight tags, use the command :HighlightTags
Tried with: Vim 7.4 and Ubuntu 14.04