/mytext"A basic search for text 'mytext'
/search\c"Search with case insensitive
/search\C"Search with case sensitive
If our cursor is on a word we can search for the next
* and for the previous occurrence
Also, if we are with our cursor on a word this word automatically
gets in our register and we can paste it in the Ex command line with
Also notice that if we used
# we don't need to reinsert that
pattern in our search, so we could simply do:
and it will substitute the every occurrence of the word we used with
Search in multiple files
vimgrep will populate the quickfix list (see :help quickfix and :help
quickfix-window in Vim) with the result of the search.
This means that we will need to use the command
:cprev to go through the
results (instead of
You can as well open the quickfix window with
:copen and go through the results.
:vimgrep /pattern/ *"search in every files of the working directory the word 'pattern'
:vimgrep /pattern/ a.txt b.txt c.txt"searches the word 'pattern' in the mentioned files
vimgrep /pattern/ *.php"will search 'pattern' in every php files
vimgrep /pattern/ **/*.php"will search 'pattern' in every php files in every directory and "subdirectory