1

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?

Stooop! http://o7.no/1jYmhYl

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
MaiaVictor
  • 51,090
  • 44
  • 144
  • 286
  • What about changing your bad habits instead of looking for a way to mitigate their effect? – romainl Mar 07 '14 at 08:50
  • It is not a bad habit at all, it allows for a faster workflow in many situations, as it cuts the need to read state (current opened file). – MaiaVictor Mar 07 '14 at 08:56
  • It is a bad habit because it breaks your workflow and you end up here asking for a solution to complete strangers. If it was a good habit, you wouldn't ask for help. – romainl Mar 07 '14 at 09:10
  • 2
    If it doesn't work, how could it be a good habit? Anyway, a real good habit is to ask for help or request a feature on a Vim plugin on that plugin's issue tracker instead of a generic site like SO. – romainl Mar 07 '14 at 09:22
  • Are you in a bad day? I've managed to solve my problem, by the way. Any interested reader might check my answer. – MaiaVictor Mar 07 '14 at 09:30
  • 1
    Please understand @romainl's grumpiness; your question doesn't show any research effort, it's just a (very specific) problem description, and therefore doesn't fit this site. I commend you for finding and posting an answer, but please take this to CtrlP's author (and then delete the entire question here). – Ingo Karkat Mar 07 '14 at 10:51
  • Except you both are wrong. This question is in accord to SO's guidelines. If you don't think so, the right channel to express it is by flagging it for moderation attention or voting for closure on the links under the main posts. Feel free to use those. – MaiaVictor Mar 09 '14 at 04:19

1 Answers1

0

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.

MaiaVictor
  • 51,090
  • 44
  • 144
  • 286