Getting 'git grep' to work effectively in vim

非 Y 不嫁゛ 提交于 2019-12-01 16:19:49

This works for me:

:command -nargs=+ Ggr execute 'silent Ggrep!' <q-args> | cw | redraw!

You can use the <args> symbol to insert the arguments given to your custom command:

:command -nargs=+ Ggr execute 'Ggrep' <q-args> | cw

Note: As the :Ggrep command doesn't have the -bar argument, it cannot be chained, so :execute has to be used.

Already mentioned in one of the comments, but I thought the plugin-recommended solution on the fugitive.vim site deserved its own answer:

autocmd QuickFixCmdPost *grep* cwindow

(from: https://github.com/tpope/vim-fugitive)

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