Ctags is great stuff. Suppose you have a file opened in your vim with some function declarations which reside in another file. But you do not remember what the functions did anymore. Then you need ctags. Ctags creates a list of tags or references to another file.

Technical Stuff

You go into the directory, where you want to have your ctags file and type ctags -R. It will then generate a file called “tags”. Now you need to point vim to that file, via :set tags=tags in vim. Or alternatively, like I have done, you write set tags=./tags;/ in your .vimrc. What that does is tell Vim to search in the current directory for a file called tags, then in the directory above, and so on, stopping at the root. In Vim you can now move your cursor over a tag/functionname and press ctrl+]. You will get immediately to the declaration of the function. With ctrl+t you can return to the original position.

Latex and Bibtex

I wanted to use ctags with latex. I wanted to jump from the \refs to the corresponding \labels. Furthermore if i have referenced some stuff from the bibliography with \cite, i wanted to jump there as well. Unfortunately the last thing does not work in ctags out of the box. But you can fix it, if you put the following in your ~/.ctags file. Thats a config for ctags in case you didn’t know.

--regex-tex2=/\\label[ \t]*\*?\{[ \t]*([^}]*)\}/\1/l,label/


Now go out and conquer the world with your new ctags skillz. Zardoz has spoken.


06 November 2014


Computer Stuff