sponsor Vim development Vim logo Vim Book Ad

basic Tip #123: use functionality similar to the * search on multiple files

 tip karma   Rating 17/8, Viewed by 1454 

created:   September 28, 2001 17:22      complexity:   basic
author:   * type grep      as of Vim:   6.0

The use of star as in vimtip#1 and vimtip#5 is great, here is how to use this type of search accross a
whole directory:
Just add the mappings (or choose different letter combinations):
map gr :grep <cword> *<cr>  
map gr :grep <cword> %:p:h/*<cr>  
map gR :grep \b<cword>\b *<cr>
map GR :grep \b<cword>\b %:p:h/*<cr>


mapping one will search for the word under the cursor (like g*) in any of the files in the current directory
mapping two will search for the word under the cursor (like g*) in any of the files in the same directory as the current file
mapping three will search for the word under the cursor by itself (i.e. surrounded by word boundary like *) in any of the files in the current directory
mapping four will search for the word under the cursor by itself (i.e. surrounded by word boundary like *) in any of the files in the same directory as the current file

Benoit

 rate this tip  Life Changing Helpful Unfulfilling 

<<Skip blank lines when folding text. | Number a group of lines >>

Additional Notes

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 [email protected] after searching the archive. Help Bram help Uganda.
Sponsored by Web Concept Group Inc. SourceForge Logo