3

I've recently mapped jj to <ESC> in insert mode for quick escaping. While everything is functional, I find the brief delay after typing j while it waits for a second input very distracting.

Is it possible for a j to always be instantly inserted into the buffer, then if I press j again the first one is removed before returning to normal mode?

Do I need to use some sort of script for this? I've tried fiddling with the timeoutlength and ttimeoutlength options but they don't seem to do what I want.

  • 1
    While I understand you point, I couldn't reproduce it. Can you try with vim -Nu NONE ? – nobe4 Aug 23 '16 at 8:58
  • 1
    @nobe4 I feel stupid now, assumed this was the default behaviour with vim but it's actually a problem with the vim emulator in my IDE. Don't think it's fixable, but thanks for clearing it up! – Charlie Collard Aug 23 '16 at 9:24
  • 1
    When in doubt, always try from scratch vim :) – nobe4 Aug 23 '16 at 9:28
0

Add <nowait> to map command, which will prevent this delay. It will instantly leave insert mode as soon as the second j is pressed, as well as remove initially typed j. Also if you need to type literal "jj", you'd need to wait a bit, but it's very rare. Also you won't be able to map something like jjj as it won't wait for any character after jj (which is probably ok for most). See :help map-nowait for more information.

inoremap <nowait> jj <ESC>
  • <nowait> was added in Vim version 7.3.1261

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.