Where developers come to connect, share, build and be inspired.


Ignoring .gitignore files in Unite.vim


Everyone loves Unite's file_rec/async file searcher, but it can be slow and unhelpful if it's not tuned properly.

The first thing that can be done to make Unite's file search faster is to use ag instead of the default, find. Unite is pretty smart, and it will use ag if it's available, so a simple brew install ag will get you rolling on Mac (installation instructions are on Github for other platforms).

By default, ag ignores files which are in your project's .gitignore (or .hgignore), but that behavior has been disabled in Unite. Luckily, we can reenable it pretty easily by changing the command Unite uses to search files for file_rec/async by doing something like:

let g:unite_source_rec_async_command= 'ag --nocolor --nogroup --hidden -g ""'

in vimrc. You may want to wrap this with a if executable('ag') if you're trying to keep your config portable.

After making this change, you may see inconsistent results in your Unite buffer because of the Unite cache. To clear the cache, <C-l> within a unite buffer.

Hopefully this speeds up your filematching!


  • D2ec30e55fdefdfba201cf408bb392d4

    One of the best things I've found on this site. Thanks

  • A204ca511ddee820957e715d6d363548

    Does this work with the current version of Unite? Can't get it working.

  • User-avatar

    In the latest version of unite:

    let g:unite_source_rec_async_command='ag --nocolor --nogroup -g ""'
  • Bcecdef24aac34873f7a5e7dec8a3e00

    Thanks, man! I

  • F45e5407b9549a669527086ce33e2a35

    Kudos for refreshing the unite cache. It was driving me crazy!

  • 3dda5dfd21d398021466f71f871920de

    Looks like it is array now:

    let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '--hidden', '-g', '']

Add a comment