让'git grep'在vim中有效工作 [英] Getting 'git grep' to work effectively in vim

查看:102
本文介绍了让'git grep'在vim中有效工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Fugitive.vim允许我运行git grep命令;不幸的是,结果没有存储在quickfix-list中,因此我需要在:Ggrep之后运行:cw才能获得易于解析的结果列表.

Fugitive.vim allows me to run git grep commands; unfortunately, the results are not stored in a quickfix-list, so I need to run :cw after a :Ggrep in order to have an easily parseable result list.

我想输入:Ggr "def my_function"而不是:

:Ggrep "def my_function"
:cw

如何在我的.vimrc文件中定义此:Ggr命令?

How can I define this :Ggr command in my .vimrc file?

编辑

一旦定义了:Ggr命令,我就可以将光标下的单词映射到git grep,这真的很棒:

Once the :Ggr command is defined, I can map to git grep on the word under the cursor, which is really awesome:

nnoremap <C-F> :Ggr <cword><CR>

推荐答案

这对我有用:

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

这篇关于让'git grep'在vim中有效工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆