Vim CtrlP Plugin: Manually set root search directory?

Jonah picture Jonah · Aug 8, 2012 · Viewed 13.3k times · Source

I have read through the docs but cannot figure out if this is possible.

I want to keep the default setting of g:ctrlp_working_path_mode = 2, but I want the ability to manually override that for all buffers in the current window if I want.

Specifically, I want to issue a ctrlp command or change a ctrlp config variable that sets the root search directory, such that is uses that directory for all future searches, regardless of which buffer I'm in.

Bonus Question: Is it possible to set two root directories, so that it searches both of them and combines the results?

Thanks!

Answer

Chandresh Pant picture Chandresh Pant · Dec 18, 2012

Try this:

let g:ctrlp_working_path_mode = 'ra'

'c' - the directory of the current file.

'r' - the nearest ancestor that contains one of these directories or files: .git .hg .svn .bzr

'a' - like c, but only if the current working directory outside of CtrlP is not a direct ancestor of the directory of the current file.

0 or '' (empty string) - disable this feature.

Source: https://github.com/kien/ctrlp.vim

Also, here: https://github.com/kien/ctrlp.vim/issues/292 , the author has provided one way to set fullpath:

:CtrlP /var/www/myproject/bla/bla/theme