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

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -