1

I have problems configuring the vim plugin CtrlP. I usually work with files in 3 different directories say C:/A,C:/B/D,J:/A When I start vim and try to find the file CtrlP do not find any

So how can I say CtrlP to look in those directories first ? Secondely I'd like CtrlP to remember all the files I opened as I am likely to open them again how can I tell CtrlP to do this ?

Here is my config

"=============================
"=========== CTRLP ===========
"=============================
">>Use this option to change the mapping to invoke CtrlP in |Normal| mode
let g:ctrlp_map = '<c-p>'
">>Set the default opening command to use when pressing the above mapping
let g:ctrlp_cmd = 'CtrlP'
">>searching by filename (as opposed to full path)
let g:ctrlp_by_filename = 0 "in {0,1}
">>When opening a file, if it's already open in a window somewhere, CtrlP will try
"  to jump to it instead of opening a new instance
let g:ctrlp_switch_buffer = 'E'
">>Set the directory to store the cache files
let g:ctrlp_cache_dir = 'C:/Travail/Tools/vim-7.4.020-python-2.7-python-3.3-windows-x86/bundle/ctrlp.vim-master/cacheFiles'

Bonus question: in this plugin, like in some others I'd like to mention $VIM which for me is C:/Travail/Tools/vim-7.4.020-python-2.7-python-3.3-windows-x86, but here it looks like CtrlP don't understand it how can I modify g:ctrlp_cache_dir to use $VIM

statquant
  • 13,672
  • 21
  • 91
  • 162

1 Answers1

3

Your problem is not really related to CtrlP as it simply tries to follow Vim's own patterns.

One of those patterns is "the working directory": it is set automatically when Vim starts and can be changed later but it's usually the top-level directory of your project. For CtrlP and Vim to be able to find your files, you'd have to set the working directory to a parent of your three directories. This is done with :cd /path/to/dir but I have the impression that you won't be able to find such a dir on Windows.

Alternatively, you can add mappings to your vimrc:

nnoremap <key> :CtrlP /path/to/dir1<CR>
nnoremap <key> :CtrlP /path/to/dir2<CR>
nnoremap <key> :CtrlP /path/to/dir3<CR>

and use :CtrlPMRU or :CtrlPMixed.

And I agree with Ingo, this is Issue Tracker Stuff.

But, really, consolidating all your stuff and fixing your workflow is what you need.

romainl
  • 186,200
  • 21
  • 280
  • 313
  • Ok but surely there is a way for CtrlP to remember some files that have been opened if previous sessions no ? About the working dir, can't I specify it some other way, I don't want to define mappings to do something like this, isn't there an option to specify those directories for CtrlP to scan those dirs each time ? – statquant Oct 04 '13 at 15:56
  • :CtrlPMRU is the command to find previous files as I wrote in my answer. Did you read it? And :help ctrlp? – romainl Oct 04 '13 at 17:03