How to use ack or ag in vim using Unite.vim?

I found many pages with configuration examples, for example:

let g:unite_source_grep_command = 'ag' let g:unite_source_grep_default_opts = \ '--line-numbers --nocolor --nogroup --hidden --ignore ' let g:unite_source_grep_recursive_opt = '' 

or

 " Use ag for searching let g:unite_source_rec_async_command = \ 'ag --follow --nocolor --nogroup --hidden -g ""' let g:ackprg = 'ag --nogroup --column' nnoremap <space>/ :Unite grep:.<cr> 

Unfortunately, I really do not understand what they are doing or why. What I played with him and got parts of what I want to work with.

Ideally, I just like something similar to what Ack.vim does:

  • I pressed a few key cards, say
  • I put my search query
  • This opens up the Unite.vim buffer split on top, which asynchronously uses ack or ag to search for my search query.
  • I can navigate through the results and select one or more to open in splits
+5
source share
1 answer

I may be missing the spirit of this question, but if you just need to configure Unite with ag, it's simple: in your .vimrc add:

 let g:unite_source_grep_command="ag" let g:unite_source_grep_default_opts="-i --nocolor --nogroup" 

In vim, you invoke the search as follows:

 :Unite grep:. pattern: foobar 

Note. Unite does not come with predefined mappings, so you need to add your own. If Unite has too much functionality for your needs, consider using Ack.vim with ag (Ag.vim is no longer supported.) Both plugins make your ideal use of patten; but Unite does a whole bunch more.

0
source

All Articles