Using ack for search within project via Vim

Hey guys,

Picked up a few things from Practical Vim yesterday. I was looking for a way to search within entire Dgraph directory, ignoring vendor folder, and then going over the results, all within Vim.

" Use ack for vim grep
set grepprg=ack\ --ignore-dir\ vendor\ --nogroup\ --column\ $*
set grepformat=%f:%l:%c:%m

This allows you to run things like :grep 'UidList', which then opens a quick fix list of all results. To make navigation through this easier, Tim Pope has a nice plugin, that you can install. This is my set up via Vundle.

" Navigation for quick fix and other vim lists
Plugin 'tpope/vim-unimpaired'

Now you can jump through the list using ]q for going one result forward and [q for one result backward. Also, there’s a whole range of commands starting with :c that you can use to navigate the list.

This should make finding things and navigating them much easier. Enjoy!

1 Like