ctrlp.vim icon indicating copy to clipboard operation
ctrlp.vim copied to clipboard

How to prevent ctrlp from indexing $HOME

Open fingermark opened this issue 10 years ago • 6 comments

I am not sure where to go with this question, but if I open up vim in $HOME and hit ctrl-p (because I thought i was in a different working directory) it will take forever to index and pretty much hang. I want to be able to tell ctrl-p to either not run when the working directory is $HOME or to ignore $HOME (but still allow for $HOME/projects/...). What's the best way to handle this?

fingermark avatar Apr 22 '14 18:04 fingermark

Hi, I had a similar problem. If i'm in a project, do a quick :e of ~/.vimrc, and then hit ctrl-p, blammo. Everything locks up for 30 seconds.

Removing 'a' from g:ctrlp_working_path_mode fixed it for me: https://github.com/bronson/dotfiles/commit/4126863544da4cf20c016f728ed3586dda617f44

This doesn't help when you start vim in your homedir, alas. I just remember not to do that...

bronson avatar Jun 19 '14 19:06 bronson

Quite a primitive workaround:

nnoremap <LEADER>f :call RunCtrlP()<CR>

fun! RunCtrlP()
  lcd %:p:h
  if (getcwd() == $HOME)
    echo "Can't run in \$HOME"
    return
  endif
  CtrlP
endfunc

Note that I'm changing the working directory to that containing the current file. It fits my workflow but may not necessarily fit yours.

aandrieiev avatar Jan 03 '16 05:01 aandrieiev

I use ag as my ctrlp user command

if executable('ag')
  let g:ctrlp_user_command = 'ag %s --nocolor -g ""'
endif

and then any top-level directories in my home that don't usually contain text files go in my .agignore.

rlue avatar Mar 14 '17 03:03 rlue

Same problem, how to cancel indexing?

I just wanted to edit some quick file and then... Ctrl+P and BUM! only exit is force closing VIM

eduardoarandah avatar Apr 02 '19 04:04 eduardoarandah

Inspired by @aandrieiev 's answer. This will also work:

  let g:ctrlp_user_command = '[ $PWD == $HOME ] && echo "In HOME Directory" || ag %s ""'

You can replace ag %s "" with any file listing command to run, e.g. with find: find %s.

dohsimpson avatar Jul 26 '19 13:07 dohsimpson

I can get out of indexing easily by pressing Ctrl+C one or two times.

ravexina avatar May 07 '20 10:05 ravexina