Vim Tips Wiki
No edit summary
(Standard format.)
 
Line 1: Line 1:
  +
{{ScriptComments|utags: find usage of a word (tag) in the project}}
= '''UTAGS''' =
 
 
== What it is. ==
 
 
   
  +
==Overview==
 
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.
 
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.
   
  +
==Wiki procedures==
  +
Hi luinnar. Sorry that I have removed most of the text you put here, but it is confusing for people if there are multiple places where a script is documented. It's almost certain that after some updates, any documentation here would differ from documentation at vim.org, and that causes trouble. Documentation should be at the script page, or included with the download. This page is for users to comment on the script (and for the author to reply, if wanted). We don't use email here. The wiki procedure is for the author (or anyone interested) to create an account on this site, and put your email into the account (there is no spam). Then you can choose to "follow" this page, and your preferences allow you to receive an email whenever this page is updated. Ask if you have any questions. [[User:JohnBeckett|JohnBeckett]] ([[User talk:JohnBeckett|talk]]) 10:59, November 20, 2012 (UTC)
   
  +
==Comments==
== How to get it. ==
 
 
You should copy the following files on your machine:
 
 
utags (shell script)
 
find_above (shell script)
 
findusage.vim
 
 
(which can be downloaded from here:
 
http://www.vim.org/scripts/script.php?script_id=3778 or here:
 
http://luinnar.narod.ru/tools/utags/index-en.html)
 
 
Copy the first two files 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.
 
 
The last file (findusage.vim) – is a plugin for vim, copy it into the folder $HOME/.vim/plugin/ (if this directory doesn't exist create it!).
 
 
== How to use it. ==
 
 
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 = ","
 
 
 
== Going though results. ==
 
 
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!
 

Latest revision as of 10:59, 20 November 2012

Use this page to discuss script 3778 utags: find usage of a word (tag) in the project

  • Add constructive comments, bug reports, or discuss improvements (see the guideline).
  • Do not document the script here (the author should do that on vim.org).
  • This page may be out of date: check the script's vim.org page above, and its release notes.

Overview[]

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.

Wiki procedures[]

Hi luinnar. Sorry that I have removed most of the text you put here, but it is confusing for people if there are multiple places where a script is documented. It's almost certain that after some updates, any documentation here would differ from documentation at vim.org, and that causes trouble. Documentation should be at the script page, or included with the download. This page is for users to comment on the script (and for the author to reply, if wanted). We don't use email here. The wiki procedure is for the author (or anyone interested) to create an account on this site, and put your email into the account (there is no spam). Then you can choose to "follow" this page, and your preferences allow you to receive an email whenever this page is updated. Ask if you have any questions. JohnBeckett (talk) 10:59, November 20, 2012 (UTC)

Comments[]