0

Ctrlp currently searches/indexes my entire home directory, how can I tell it to only index ~/code?

hermancain
  • 1,452
  • 2
  • 18
  • 24

2 Answers2

2

You have several options to configure where CtrlP will search for files. You will have to add these to your .vimrc file.

For example, in my case I use ag to perform the search:

let g:ctrlp_user_command = 'ag %s -l --hidden --nocolor -g "" --ignore .git'

Normally CtrlP will look into the directory of the current project. If you always want to search in ~/code like you ask, you could add this custom command (in OSX):

let g:ctrlp_user_command = 'find ~/code -type f ! -path "*.git*"'

You could even add extra directories, like:

let g:ctrlp_user_command = 'find ~/code ~/foo ~/bar -type f ! -path "*.git*"'

However, I advise to not fix the directory where CtrlP will look and leave it to search for the project of the current file (see let g:ctrlp_working_path_mode)

Ignacio
  • 688
  • 5
  • 17
1

CtrlP searches/indexes your entire home directory because that's what you ask it to do.

You are probably starting Vim in your $HOME and doing :CtrlP from there. Since the working directory is $HOME you shouldn't be surprised that CtrlP scans all of it.

The solution to this non-issue is simply to use your shell and Vim as they are supposed to be used:

$ cd ~/code
$ vim
romainl
  • 186,200
  • 21
  • 280
  • 313