Skip to content
Shin Okada edited this page Aug 15, 2015 · 5 revisions

Ggrep

Use :Ggrep "words" to find in a working directory. Ggrep is a part of fugitive plugin.

Resources

Vim.wikia

Vim+Grep

Using Grep from Inside Vim

Basics

# 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.

Case sensitive and case insensitive

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'

From Vim+Grep

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.

10. Searching.md


  1. Grep
Clone this wiki locally