Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VIM search multiple closed files

Tags:

vim

search

One thing that I like to do from time to time is do a quick search on the directory I am working on and find all the references to a specific string, specially when debugging code from some one else. Is it still not possible for VIM to do such search? Is there an alternative to do it directly with plain terminal?

ATM (since I'm still learning VIM) I do the search in TextMate and find the string that way.

like image 804
Helmut Granda Avatar asked Dec 16 '22 05:12

Helmut Granda


1 Answers

You can use the vim command :vimgrep. This will search for a pattern in the specified files and puts the results in the quickfix window which you can then use to jump to a specific match. So for example to search for foo recursively in every .php file in your current directory you would do

:vimgrep "foo" **/*.php

Another option is the command :grep which actually calls the grep program (or whatever grepprg is set to). It also puts the results in the quickfix window for easy navigation. However this requires that you have grep on your system.

like image 122
David Brown Avatar answered Dec 21 '22 10:12

David Brown