VIM search for pattern into quickfix

二次信任 提交于 2020-12-28 07:45:06

问题


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.


回答1:


Use caddexpr:-

g/<pattern>/caddexpr expand("%") . ":" . line(".") . ":" . getline(".")



回答2:


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



来源:https://stackoverflow.com/questions/1330532/vim-search-for-pattern-into-quickfix

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!