Question

I'm getting started using vim for a week and many things still new to me. During the research, I found Unite.vim is extremely great. However, I cannot manage to get this command works:

nnoremap <leader>f :<C-u>Unite -start-insert file_rec/async.

I looked into doc file and it says the following:

file_rec/async Same as |unite-source-file_rec|, but get files asynchronously.

Note: This source requires vimproc.

Note: This source requires "ag" or "find" command.

Note: Windows "find" command is not supported.

I'm using vim windows and don't find the way to have Ag or find compatible commands (I guess it would be for mac/linux) Any instructions would be appreciate. Tks :)

Was it helpful?

Solution

All of this is assuming you have cygwin, and vim with pathogen managing your plugins:

Before you use the file_rec/async command, you need to have vimproc, because what happens is Unite runs the search in another process, and then searches through the results with your vim process:

mkdir -p ~/.vim/bundle
git clone https://github.com/Shougo/vimproc.vim.git ~/.vim/bundle/vimproc.vim
cd ~/.vim/bundle/vimproc.vim
make -f make_cygwin.mak # <-- This is directly from the vimproc readme

Next, ensure that it works by running vi, and staying in command mode and entering:

:Unite -start-insert file_rec/async

If that works, then I would advise you to setup your binding in ~/.vimrc like this:

nnoremap <C-u> :Unite file_rec/async<cr>

Getting ag on your machine might be difficult, as the documentation states that it's "Complicated" and advises you to install a package manager for windows and some libs: https://github.com/ggreer/the_silver_searcher/wiki/Windows

However, if you do manage to get ag on your machine, here is the configuration I've gotten it to work with Unite.vim with in my ~/.vimrc:

" Use ag for search
if executable('ag')
  let g:unite_source_grep_command = 'ag'
  let g:unite_source_grep_default_opts = '--nogroup --nocolor --column'
  let g:unite_source_grep_recursive_opt = ''
endif

OTHER TIPS

Ag (a.k.a. the Silver Searcher) is a utility like ack, you can find it here, there also seems to be a dedicated Windows port.

Alternatively, you can try the GNU find Windows port from the unxutils project, or use Cygwin for Windows.

Get vimproc neccesary dll from http://www.kaoriya.net/software/vim/. On website there are 32 and 64bits version downloads.

Inside each zip there is a plugins directory (example with 64bits): "vim74-kaoriya-win64-20150628.zip\vim74-kaoriya-win64\plugins\vimproc\autoload\" where you can find it without compile.

For ag use windows port as @Ingo Karkat says.

NOTE: ag suffers from searchs on paths long than 256 chars (at this time). Use platinum searcher if that is a problem in your case.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top