Take the 2-minute tour ×

Basically I need to create a quickfix buffer listing all lines that match a regex. What is the best way?

The global command may not be the best, but I think it should be usable. The output of the global command is perfect, but I need it to hyperlink the matching lines.

share|improve this question
add comment

2 Answers

up vote 9 down vote accepted

Use caddexpr:-

g/<pattern>/caddexpr expand("%") . ":" . line(".") . ":" . getline(".")
share|improve this answer
Cool ... and then a call to :cwindow, of course. –  Dave Ray Aug 25 '09 at 20:07
add comment

You can also not use the global command and stick with what is built-in. Use the vimgrep command as below:

:vimgrep /pattern/ %

And then :copen or :cwindow

share|improve this answer
Personally, I think this is a better answer because it does the exact same thing as the accepted answer, but in a simpler, more compact fashion. –  Michael Mar 7 '13 at 15:16
add comment

Your Answer


