-
-
Notifications
You must be signed in to change notification settings - Fork 2
10.1. Grep
Use :Ggrep "words"
to find in a working directory. Ggrep
is a part of fugitive plugin.
# check your pwd
:pwd
# Search within the project folder
:vimgrep /pattern/gj ./**/*.php
# display it
:cw
g
flag will return all matches. With j
flag, Vim won't jump to the first match.
:cn # to jump to the next match.
Search 'copyright'
:set smartcase
/copyright " Case insensitive
/Copyright " Case sensitive
/copyright\C " Case sensitive
/Copyright\c " Case insensitive
See:
:help /\c
:help /\C
:help 'smartcase'
Using macro.
:qccwcommand<Esc>:w<Ctl-W>jj<Enter>q
This macro will change the current ‘path_to_command’ word to ‘command’, write the file out to disk, change window splits to the grep search results, move down one line in the results and navigate to that result’s location. I ran the macro by hitting @c and then verifying the line selected was one that I wanted to change. For a few instances where I did not want to change the line, I manually navigated to the next search result and then re-ran the @c macro.
Important: The Tables of Content are generated. Any change will be overridden on the next update.
For more information: GitHub Wikifier