Home

Awesome

Vim-Tags

Vim-Tags version 0.1.0

The Ctags generator for Vim

Copyright (c) 2012-2014 Szymon Wrozynski and Contributors

About

Ctags support is a great feature of Vim. One approach to make use of Ctags is the way of Tim Pope's plugins. For example in Rails projects, Ctags are generated automatically while Bundler is running and installing new gems.

Vim-Tags plugin treats Ctags like more tightly coupled within a concrete project. It creates '.tags' files directly in the root project directory. Also, it can perform tags creation upon each file save through forking - available under Unix-like operating systems. This option, however, may require some tweaking under Windows.

Vim-Tags is under active development. Currently, besides its main features, it provides some support for Ruby/Rails projects (it can generate tags for gems listed in 'Gemfile.lock' file).

Installation

Place in ~/.vim/plugin/tags.vim or in case of Pathogen:

cd ~/.vim/bundle
git clone https://github.com/szw/vim-tags.git

In case of Vundle that would be:

Plugin 'szw/vim-tags'

placed in your .vimrc file

Moreover, Vim-Tags requires ctags utility. On Ubuntu you can install it with:

sudo apt-get install exuberant-ctags

On Mac OSX you could use Homebrew:

brew install ctags

Please, don't forget to star the repository if you like the plugin. This will let me know how many users it has and then how to proceed with further development :).

Ruby Manager

If you are using a Ruby Manager such as chruby, rvm, rbenv etc, be sure to have your Ruby Manager integrated with Vim.

A simple way to check this is by executing bundle show --paths in your Vim in the command-line mode.

:!bundle show --paths

If it shows your current Gems (based on your Gemfile) it is probably working fine.

Usage

The plugin has only one command and a few options described in the Configuration section.

:TagsGenerate

This command will generate one or more tags files but only if the main tags file exists. The presence of that file acts as an indicator actually. By the main tags file I mean the "tags" file collecting tags from all files and subdirectories of the project root directory.

Moreover, this command will also update the tags setting of Vim with all new tags files found in the project root as Vim-Tags caches relative tags paths and updates tags settings automatically.

By default, this command is also executed upon each file save.

Besides the main "tags" file the project may have more tags files for different directories and a special Gemfile.lock.tags file for tags gathered from a Bundler project.

For the first time, when there are no tags files in your project yet, you can force generating them by the bang version of the :TagsGenerate command:

:TagsGenerate!

The bang version of the command forces generation for all "tags" files.

Additionally, you can exclude some directories from the main "tags" file, especially if they contains rarely changed and heavy content, i.e. third-party libraries. Those directories must be placed directly at the project root.

To exclude them, make empty files named exactly after those directories with ".tags" suffixes: e.g. "vendor.tags" for the "vendor" directory. Then, the plugin will be watching modification times of those directories and corresponding tags files and perform tags generation only if necessary.

Vim-Tags can read files containing patterns to exclude from tags generation. By default it seeks among '.gitignore', '.svnignore', and '.cvsignore' files in the current directory. You can change this behavior by setting proper configuration options explained later.

The last but not least feature is the Ruby Bundler support. It is easy and straightforward. If your project root contains "Gemfile.lock" file, the plugin will be generating tags for all your Bundler gems referenced in the Gemfile. Here, "Gemfile.lock" modification time will be taken to find out whether the tags generation is required, just like in the custom directories case explained earlier. The plugin will create "Gemfile.lock.tags" file automatically

Configuration

Vim-Tags assumes that you have 'ctags' utility available in your shell. However it is possible to change or improve shell commands used by the plugin, e.g. in case you have to point a proper binary with absolute path or tweak some options.

Vim-Tags can be configured by setting some global variables in your '.vimrc' file. If you want to have some custom settings valid only for the current project create a local '.vimrc' file with those settings and add the following snippet to your main '.vimrc' file:

set exrc
set secure

This will allow Vim to use your custom .vimrc in the current working directory.

The Vim-Tags available variables are:

Authors and License

Vim-Tags plugin was written by Szymon Wrozynski and Contributors. It is licensed under the same terms as Vim itself. For more info see :help license.