vim ♥ ack
Switch branches/tags
Clone or download
Pull request Compare This branch is 105 commits ahead, 21 commits behind tsibley:master.
Latest commit 3f9e73a Apr 20, 2018

README.md

vimack

vimack 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 vimack converts the strings.

vimack is useful at the bash command line, it is not used within vim.

Usage

vimack 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

Install

Clone the repository and source a file to add vimack's command into bash

git clone https://github.com/jalanb/vimack.git
source vimack/vimack.sh

Merge vimack's ackrc file into ack's config file in $HOME

vim -d vimack/ackrc ~/.ackrc

Options

Because it needs to handle options for both ack and vim, vimack 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

How does it work?

vimack 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.

Limitations

  • vimack only provides the commands I have needed - searching in shell, python, and web files. But they are very easy to extend
  • vimack needs to handle options from the shell command line for both ack and vim. The code which handles this is a "good enough" hack

Readers who got this far went on to view:

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

Who Doesn't Love Badges?

Build Status Test Coverage