根据从标准输入填充快速修复窗口? https://www.reddit.com/r/vim/comments/7ieb3p/filling_the_quickfix_window_from_stdin/您可以执行以下操作:
rg --vimgrep 'pat' | vim -q /dev/stdin
您需要提供--vimgrep
将 ripgrep 的输出转换为 Vim 的正确格式。-q
将文件读入快速修复列表。
或者
通过以下方式从 Vim 内部进行搜索:grep
将以下内容添加到您的vimrc
file:
set grepprg=rg\ --vimgrep
set grepformat^=%f:%l:%c:%m
现在你可以做:grep 'pattern'
它将填充快速修复列表。重做您的搜索就像:grep
随后是一些<up>
按 返回您的相关信息:grep
.
快速修复命令
-
:cnext
/:cprevious
在快速修复列表中向前和向后导航快速修复
-
:cfirst
/:clast
跳转到快速修复列表的开头和结尾
- Use
:copen
打开快速修复窗口。使用<cr>
跳转到某个条目
- Use
:cclose
关闭快速修复窗口
- Use
:cc
显示当前错误。
-
:colder
/:cnewer
跳转旧/新的快速修复列表
我建议您创建映射:cnext
and :cprevious
。我个人使用未受损.vim https://github.com/tpope/vim-unimpaired它提供了]q
& [q
映射为:cnext
and :cprevious
.
如果您希望快速修复窗口自动打开,请将以下内容放入您的vimrc
:
augroup autoquickfix
autocmd!
autocmd QuickFixCmdPost [^l]* cwindow
autocmd QuickFixCmdPost l* lwindow
augroup END
有一个Vimcasts http://vimcasts.org/关于这个主题的剧集:使用 :vimgrep 搜索多个文件 http://vimcasts.org/episodes/search-multiple-files-with-vimgrep/.
项目范围的搜索和替换
如果您正在使用:grep
/:vimgrep
作为做一个项目范围内的搜索和替换 http://vimcasts.org/episodes/project-wide-find-and-replace/那么我建议你使用:cdo
/:cfdo
(在 Vim 7.4.980+ 中)。
:grep 'foo'
:cfdo %s/foo/bar/g|w
如需更多帮助,请参阅:
:h :grep
:h 'grepprg'
:h quickfix
:h :cnext
:h :copen
:h :ccl
:h :cc
:h :colder
:h :cdo
:h :cfdo