search - Is it possible to use vimgrep for a visual selection of the current file? -


i search vimgrep within visual selection of current file , not whole file. possible , how? couldn't find case google or in vim help.

the reason why want because need result in quicklist (copen) , :g/foo showing matching lines @ bottom not doing job.

yes, can, vim has special regular expression atoms mark positions, , start , end of visual selection marked '< , '>. there atoms on / before / after mark, need combine cover entire range of selected lines:

on selection start | after selection start , before selection end | on selection end.

to limit search current file, special % keyword used.

:vimgrep/\%(\%'<\|\%>'<\%<'>\|\%'>\)foo/ % 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -