regex - Display all lines matching a pattern in vim -


i search particular string in file in vim, , want lines matching string displayed, perhaps in vim window.

currently this:

search 'string'

/string 

and move next matching string

n or n 

bur, want lines matching string @ 1 place.

for example:

1 here string

2 nothing here

3 here same string

i want lines 1 , 3 displayed below, highlighting string

1 here string

3 here same string

:g/pattern/#<cr> 

lists lines matching pattern. can :23<cr> jump line 23.

:ilist pattern<cr> 

is alternative filters out comments , works across includes.

the command below:

:vimgrep pattern %|cwindow<cr> 

will use vim's built-in grep-like functionality search pattern in current file (%) , display results in quickfix window.

:grep pattern %|cwindow<cr> 

does same uses external program. note :grep , :vimgrep work files, not buffers.

reference:

:help :g :help include-search :help :vimgrep :help :grep :help :cwindow 

fwiw, plugin vim-qlist combines features of :ilist and quickfix window.


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -