Some times when I'm using VIM, I try to open the file that is already opened. This happens because I have a really quick reflex when I think in editing a file, which is faster than checking which file I'm in. The problem is that CtrlP complains and locks me on itself with a big "NO ENTRIES" message, making me need to press <C-c>
to quit it. This is seriously flow-breaking. I'd just like it to quit when there is no entries - or at least when I press <enter>
, which I always do anyway.
Is this possible?
I've managed to solve the issue by patching ctrlp.vim
on .vim/bundle/ctrlp.vim/autoload/
. You need to add this function anywhere:
fu! s:OpenExit()
cal s:AcceptSelection("e")
cal s:PrtExit()
endf
and this after line 144 (one with PtrExit()
):
\ 'OpenExit()': ['<cr>'],
Also, delete the '<cr>'
string from line 123 (the one with AcceptSelection("e")
). This will ensure pressing enter
leaves CtrlP.
Anyway, what is more interesting is that you could edit the Update() function on that file in order to open a file as soon as there is only 1 match, making it faster than having to look for it.