将 Ag 与 vim 一起使用时出现参数需要错误 更多信息:Ag 命令的定义设置

问题描述

我只想使用 :Ag 命令进入交互式 ag shell(与 :Files 一样),然后开始输入我的搜索词。

但是,vim 不允许我打开 ag 交互界面。如果我输入 :Ag,它会抱怨以下错误:

E471:需要参数

如果我输入搜索词(如 :Ag something),它会打开一个包含结果的新窗格。但这不是我想要的:我想以与 ag 命令相同的方式使用 :Files

更多信息

我正在使用 thoughtbot/dotfiles

:Ag 命令的定义

:verbose command Ag

    Name              Args Address Complete    Definition
|   Ag                +            file        silent! grep! <args>|cwindow|redraw!

设置

这是我的 .vimrc 文件中启用了 ag 的部分。

" Use The Silver Searcher https://github.com/ggreer/the_silver_searcher
if executable('ag')
  " Use Ag over Grep
  set grepprg=ag\ --nogroup\ --nocolor

  " Use ag in fzf for listing files. Lightning fast and respects .gitignore
  let $FZF_DEFAULT_COMMAND = 'ag --literal --files-with-matches --nocolor --hidden -g ""'

  if !exists(":Ag")
    command -nargs=+ -complete=file -bar Ag silent! grep! <args>|cwindow|redraw!
    nnoremap \ :Ag<SPACE>
  endif
endif

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)