vim shortcut to go from command mode back to normal mode

5

2

I use nnoremap ; : to go to command mode. Is there oposite shortcut that i can add to my .vimrc so that i won't press ESC every time to go back to normal mode?

user52151

Posted 2012-12-21T14:57:01.287

Reputation: 73

Answers

1

Aborting command-line mode shouldn't be so frequent, why do you worry about having to press Esc?!

Some people remap Caps Lock to either Esc or Ctrl (outside of Vim), this also helps with leaving insert mode. Did you know that you can also use Ctrl-C to abort the command-line? Alternatively, you can define a mapping, e.g. ;; to abort the command-line:

:cnoremap ;; <C-c>

Ingo Karkat

Posted 2012-12-21T14:57:01.287

Reputation: 19 513

0

Choose some easy-to-type key sequence that you aren't likely to use in any text and map it to <Esc>. The sequence qq is not found in English, for example, so you could map it like this:

inoremap qq <Esc>

If you ever have a need to enter that sequence into some file, just precede it with Ctrl-V.

garyjohn

Posted 2012-12-21T14:57:01.287

Reputation: 29 085

Although not relevant answer, you helped me fix my problem with remaping Esc to something more reachable :) – Ratul – 2015-07-19T20:47:37.203

He wants to leave the command line, not insert mode, but the mapping is almost identical: :cnoremap. – Ingo Karkat – 2012-12-22T02:01:23.993

@Ingo Karkat: OK, thanks. I never leave command mode except when finishing the command, so despite his words, I assumed he meant to leave insert mode. – garyjohn – 2012-12-22T05:09:02.187