Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VIM Autocreating CTags

Tags:

vim

ctags

I love Ctags but the fact that every time I add a new method I need to recreate my file it can be counter productive, not only that but if I need to restart my VIM session it is even worse, also I have noticed that I need to create a CTags file for every directory I want to work with rather than just making one in the root folder and having all the folders having access to it.

Any tips and recommendations?

like image 459
Helmut Granda Avatar asked Feb 21 '23 22:02

Helmut Granda


1 Answers

I already wrote a plugin to do exactly what you need: Indexer.

It provides painless automatic tags generation for the whole project(s) and keeps tags up-to-date. You can use it independently or as an add-on for another plugin project.tar.gz.

In the first way, you can declare your projects in ~/.indexer_files like this:

[CoolProject]

/home/user/cool_project

[AnotherProject]
option:ctags_params = "--languages=c++"

/home/user/another_project/src
/home/user/another_project/lib 

And then, when you open any file from /home/user/cool_project , all this project will be indexed by ctags. Tags is generated in background, so, you do not have to wait while ctags generates tags. When you open tags from another project, tags is generated for it too. Tags from different projects is never mixed. When you save file from project, tags is silently updated. You do not have to care about it, it just works.

For detailed information, see my article: Vim: convenient code navigation for your projects, which explains the usage of Indexer + Vimprj thoroughly.

like image 113
Dmitry Frank Avatar answered Feb 27 '23 08:02

Dmitry Frank