Vim Tips Wiki
Advertisement

Previous TipNext Tip

Tip: #117 - Search all files in project quickly

Created: September 13, 2001 7:00 Complexity: intermediate Author: Manish Tehanguria Version: 6.0 Karma: 456/121 Imported from: Tip#117

Searching for a word across the project wastes most of the developres time, which can be avoided by the use of GNU Id_utils with VIM.

The procedure needs to be followed is as follows:

download GNU idutils 3.2d (mkid,lid,fid,fnid,xtokid)

from http://www.mossbayeng.com/~ron/vim/builds.html


uncompress and store these files in the directory from where vim is running.


goto the top level directory of the project, and run mkid, it will create ID file in that directory (As it is time consuming process, so be patient). copy this file ID to the directory from where vim is running.


USAGE:


Put these lines in your .vimrc:


map _u :call ID_search()<Bar>execute "/\\<" . g:word . "\\>"<CR> 
map _n :n<Bar>execute "/\\<" . g:word . "\\>"<CR> 


function ID_search() 
let g:word = expand("<cword>") 
let x = system("lid --key=none ". g:word) 
let x = substitute(x, "\n", " ", "g") 
execute "next " . x 
endfun 


To use it, place the cursor on a word, type "_u" and vim will load the file

that contains the word. Search for the next ocurance of the word in the same

file with "n". Go to the next file with "_n".


The mapping of "_u" and "_n" can be done to some other key as per your preference but I use ^K and ^L for this purpose.

Comments

Advertisement