sponsor Vim development Vim logo Vim Book Ad

utags : Find usage of a word (tag) in the project.

 script karma  Rating 246/69, Downloaded by 1530  Comments, bugs, improvements  Vim wiki

created by
Luinnar .
script type


Utags provides an ability to search for usage of a C/C++/Python/Perl function, a type name, a class method/member, a variable or any other word in a source code of a project. It's like a fast, convenient grep by the whole word. Search is performed from vim by a hot-key when cursor is on the word you want to find. It works quickly since utags uses a beforehand generated index.


First of all you should generate an index. It's done by the following command:
cd your_proj_path && utags -g . > .utags
It can take a while for big projects.
Further when you edit a file from the project and current folder is a project subfolder and the vim cursor is on the word you want to find in the project, press and release one by one two keys: <\> and <U> (without delay between pressing, quite quickly; letter U is in uppercase here, so press it holding Shift). If you have done everything right, vim opens a window in the top with a list of results.

A couple of other hot-keys limit the search area:
<\>, <D> - search only in the C/C++ headers.
<\>, <P> - search only in the current directory.
Letters D and P are in upper case here too, so press them with Shift held.

Key <\> is defined by vim configuration and can be changed, for example, on a comma by adding the following line into $HOME/.vimrc:
let mapleader = ","


You may select items from the result list using mouse double-click or using a keyboard (arrows and Enter). In order to move vim cursor in the bottom window using keyboard press <Ctrl>+<w>, <Down>, and to return to the top window: <Ctrl>+<w>, <Up>.

You also may assign hot-keys to go thru the result list faster:
map <F6> :copen<CR>
map <F7> :cprevious<CR>
map <F8> :cnext<CR>

These lines should be added to $HOME/.vimrc

If you have any question about this tool or know how to enhance it, please email me at luinnar(at)yandex.ru

Have a fun!

In English: http://luinnar.narod.ru/tools/utags/index-en.html
На русском: http://luinnar.narod.ru/tools/utags/
install details
Copy utags and find_above into any your folder which is already in the $PATH, or if there is no such folder, then create one and add it to the $PATH.

findusage.vim is a plugin for vim, copy it into the folder $HOME/.vim/plugin/ (if this directory doesn't exist create it!).

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
utags-1.2.tbz 1.2 2012-11-16 6.0 Luinnar . Supported new file types: *.cc, *.hh, *.cxx and *.hxx.

Added an option to findusage.vim plugin:
utags-1.1.tbz 1.1 2012-10-23 6.0 Luinnar . Fixed search in the current folder.
utags.tbz 1.0 2011-10-20 7.0 Luinnar . Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.