在VIM中搜索Ack的方法是如何包含.go文件?

huangapple go评论68阅读模式
英文:

How to include .go for search for Ack in VIM?

问题

这是我用于 Ack 的 .vimrc 文件,但它无法搜索 .go 文件,我想要添加对 .go 文件的支持。

let g:ackprg="ack-grep -H --nocolor --nogroup --column"

function! Ack(args)
    let grepprg_bak=&grepprg
    exec "set grepprg=" . g:ackprg
    execute "silent! grep " . a:args
    botright copen
    let &grepprg=grepprg_bak
    exec "redraw!"
endfunction

command! -nargs=* -complete=file Ack call Ack(<q-args>)

请注意,这是一个用于 Vim 的配置文件,用于在编辑器中使用 Ack 插件进行搜索。你可以将其中的 let g:ackprg="ack-grep -H --nocolor --nogroup --column" 这一行修改为适用于 .go 文件的命令,以添加对 .go 文件的支持。

英文:

Here is my .vimrc for Ack, But it can't search .go files, I'd like add .go support.

let g:ackprg=&quot;ack-grep -H --nocolor --nogroup --column&quot;

function! Ack(args)

let grepprg_bak=&amp;grepprg
exec &quot;set grepprg=&quot; . g:ackprg
execute &quot;silent! grep &quot; . a:args
botright copen
let &amp;grepprg=grepprg_bak
exec &quot;redraw!&quot;

endfunction

command! -nargs=* -complete=file Ack call Ack(&lt;q-args&gt;)

答案1

得分: 7

自从1.94版本以来,ack 内置了对 Go 语言的支持。

$ ack --help type
...
    --[no]go           .go

你可以通过传递 --go 来显式启用它,但默认情况下应该包含在搜索中。

英文:

Since version 1.94, ack has support for the Go language built-in.

$ ack --help type
...
    --[no]go           .go

You can explicitly enable it by passing --go, but it should be included in the search by default.

huangapple
  • 本文由 发表于 2014年1月27日 18:10:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/21378045.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定