使用 ack.vim 替代 VIM grep

发布时间: 2017-03-30 14:21:57 作者: 大象笔记

VIM grep 让人不爽的地方

而 ack.vim 很好的解决了这两个痛点

安装 ack.vim

Ubuntu 16.10 上首先安装依赖 ack-grep

sudo apt-get install ack-grep

VIM 上使用 Vundle 安装,现在 .vimrc 中加入

Plugin 'mileszs/ack.vim

然后打开 VIM, 执行 :PluginInstall

使用 ack.vim 的高效之处

可以使用快捷键操作 quickfix result window, 快捷键列表

?    a quick summary of these keys, repeat to close
o    to open (same as Enter)
O    to open and close the quickfix window
go   to preview file, open but maintain focus on ack.vim results
t    to open in new tab
T    to open in new tab without moving to it
h    to open in horizontal split
H    to open in horizontal split, keeping focus on the results
v    to open in vertical split
gv   to open in vertical split, keeping focus on the results
q    to close the quickfix window

禁止自动切换至第一个匹配结果

If [!] is not given the first error is jumped to.

:Ack! title -r .

即,在 Ack 后加上 ! 即可。

我是一名山东烟台的开发者,联系作者