ackvim
eases the interface beween ack and vim, so that ack
's findings can be found with vim
as well.
It helps by running ack
commands, gathering the results and using vim
to edit any found files, and telling vim
to search for similar strings to those ack
sought. The strings vim
searches for are "similar", not "the same", because the two commands use different regexp languages, so ackvim
converts the strings.
ackvim
is useful at the bash command line, it is not used within vim
.
ackvim
allows lines in bash
like
ap -w main -v
which tells ack
to search all python files for the word main, and tells vim
to open all those files searching for the word main
And it allows lines like
aai sys
which searches all python files for any "import sys" or "from sys import", and vims those files with that search
Clone the repository and source a file to add ackvim
's command into bash
git clone https://github.com/jalanb/ackvim.git
source ackvim/ackvim.sh
Merge ackvim
's ackrc file into ack
's config file in $HOME
vim -d ackvim/ackrc ~/.ackrc
Because it needs to handle options for both ack
and vim
, ackvim
provides only one option itself. Rather it provides individual commands, such as the following which add filetype options to the ack
command line
command | filetype |
---|---|
aa | --all |
ac | --code |
ae | --erl |
al | --html |
ap | --python |
at | --pyt |
(These filetypes are defined in the ackrc file included in this repository)
Some commands add other options, e.g. ai
searches in python files for imports only. RTFS for more commands
Each a...
command recognises one option -v
which runs the a...
command, and sends the results on to vim
. And, for the convenience of those using readline
's vi mode at the command line, each also has an equivalent aa...
alias.
So, to search for "fred" using ack
the command is the usual
ack fred
Or, to search only in web files:
al fred
To do the same searches, and then open the results in vim
the commands would be
aack fred
aal fred
or, equivalently
ack fred -v
al fred -v
ackvim
provides bash functions with abbreviated names, all of which eventually hand over to a python program which interprets arguments, and does some conversion of ack
to vim
regexps, before sending the correct vim
command to stdout. Bash captures that and runs it.
ackvim
only provides the commands I have needed - searching in shell, python, and web files. But they are very easy to extendackvim
needs to handle options from the shell command line for bothack
andvim
. The code which handles this is a "good enough" hack
Although this code was originally forked from viack we have diverged completely, hence the copyright claim in the LICENSE file
This code WFM and I use it daily, but caveat lector