Using the CtrlP plugin, I’m typing .. several times to get to the root directory of a project, then perform the search from there.
However after I reopen CtrlP it still searches in the directory of the current file.
How can I get it to stick to the directory that I originaly set ?
By reading its documentation, of course.
If you want CtrlP to always open in your project’s root directory, if applicable, just add this line to your
~/.vimrc:But you could also use both
:CtrlPto browse in the current directory and:CtrlpRootto browse in the root of your project.Or simply use
:CtrlPLastModeto launch CtrlP in… the last mode.If your project doesn’t fit CtrlP’s definition of a project, a simple mapping could be enough:
or you could use this option:
edit
My answer was based on the version of CtrlP currently installed on my machine.
The latest version adds an optional argument to
:CtrlPLastMode:--dirwhich does exactly what you are looking for:The
g:ctrlp_working_path_modevalues are different, too. I believeris the equivalent of2.