Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VIM search for pattern into quickfix

Tags:

vim

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.

like image 880
Ayman Avatar asked Aug 25 '09 19:08

Ayman


2 Answers

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

like image 76
Ayman Avatar answered Oct 13 '22 00:10

Ayman


Use caddexpr:-

g/<pattern>/caddexpr expand("%") . ":" . line(".") . ":" . getline(".")
like image 38
Gavin Gilmour Avatar answered Oct 12 '22 23:10

Gavin Gilmour