1

I recently found that when running Vim in GNU Screen, I have to press Escape twice to get out of insert mode.

Beyond just googling or asking in forums, I would like to see the code behind Vim executing so I can try to see what is going on myself.

How could I get a print out of what happened in Vim when I pressed the Escape key the first time? Maybe it would show that it received the key press and what command it ended up corresponding to.

12
  • Is anything displayed if you hit ctrl-v before esc?
    – B Layer
    Sep 12, 2021 at 11:25
  • If I press ctrl-v I see ^v in the bottom right of the screen. Then after pressing Escape twice like normal the characters ^[ have been written into the text file where the cursor was. Sep 12, 2021 at 16:14
  • Wait, in Insert mode you hit ctrl-v then esc and see ^[...okay that's, normal. But then you only have to hit esc one more time to leave Insert mode? Because if your bug was present in this scenario you'd have to press it twice (for a total of three escs). Weird.
    – B Layer
    Sep 12, 2021 at 16:25
  • Or are you still in Insert mode after the second esc?
    – B Layer
    Sep 12, 2021 at 16:32
  • No, after two escapes, I leave insert mode. But someone linked me to some posts on a different question of mine. It seems it's a known bug with a known solution. Screen creates a delay on the Escape key for some reason. Sep 12, 2021 at 18:02

1 Answer 1

1

For running and debugging vim, see :help terminal-debug. More likely, though, screen is eating the first escape for some reason, so vim never sees it (or, screen is holding the escape, waiting to determine if an escape sequence is coming—you can test for this by waiting for a few seconds after a single escape press. If this is the issue, you need to configure screen's timeout.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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