Skip to content
Advertisement

How to set ctag in vim editor one time

I have created ctags for my project. Now every time, I open file in vim editor I set ctag location. Is it possible to set the ctag location for one time in some where that I don’t know, So that when I open a file from my project in vim, it will start working, I do not need to fire this command set tags=~/tags. Please help.

Advertisement

Answer

Use the :echo $MYVIMRC within Vim to print the location of your .vimrc file. If the variable is not set, you’ll want to create the file yourself. Typically its location is ~/.vimrc, but as the comments mention there are other supported locations. Once you’ve created the file, you can just add the command as you normally would: set tags=~/tags. As other comments mentioned, it’s probably for the best to put your tags file in some constant, relative-to-the-project-root-folder place. I personally follow Tim Pope’s ctags guide for all my Git projects.

I mean, which would you rather have,

set tags=./tags

or

set tags=/some/project/tags,/some/other/project/tags,/yet/another/project/tags,...
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement