Search code examples
vimctags

Vim & ctags: Common ctags across all projects?


I'm just getting acquainted with Vim's CTags functionality - and it's damn handy.

One issue I have, though, is regenerating common tags for each project.

For example - I do a fair bit of work in rails, and like to generate ctags for the whole rails framework with

alias rctags="ctags -R `bundle show rails`/../*"

The issue is I have to do this for every rails project I start up.

So, what's the standard way to automatically access a set of tags in any vim session - ideally only if the opened file satisfies a specific condition. (Eg rails ctags preloaded for .rb files, but not .py files)

Any ideas appreciated


Solution

  • See :help 'tags'.

    You could use, for example:

    set tags+=~/.rails-tags
    

    Which would cause ~/.rails-tags to be searched for tags.

    (also, on the topic of tags: it's probably useful to suffix the tags variable with ;/. This means "search for a tags file in every parent of the working directory (ex, all the files /foo/bar/tags, /foo/tags, and /tags will be searched. For example, I use: set tags=tags;/).