I'm having a problem with the Esc key when I want to return to the interactive mode from the insert mode. Is there exist another key used to release the insert mode.
7 Answers
Ctrl-[ sends the same character to the terminal as the physical Esc key. The latter is simply a shortcut for the former, generally.

- 76,081
-
6I once had a real vt220 terminal, and its keyboard does not have a
Escape
key. PressingCtrl+[
was the only way to generateEscape
. – Kusalananda Mar 06 '18 at 07:53
You could try Ctrl-C, that works for me and is in my opinion easier than ESC. However I am not sure if it is enabled by default.
-
-
@cat It works basically the same in vim though. I am always using Ctrl-C instead of Esc – Erik W Dec 24 '16 at 02:54
-
-
@cat That is probably true, but it still is a good solution since it handles it as ESC (enter normal mode) – Erik W Dec 24 '16 at 03:05
-
@ErikW no, you need to install a handler / trap for your process yourself, you do not get it for free – cat Dec 24 '16 at 03:08
-
2@cat: You do get it for free, because vim has that handler in place. You don't have to do anything yourself. This answer works out of the box; I just tried it. Does it work in general for any application? No, but that's not what was asked for. – Lightness Races in Orbit Dec 24 '16 at 16:44
-
@LightnessRacesinOrbit It wasn't clear to me this question is supposed to be specific to vim and not all terminal console applications in Unix and Linux. – cat Dec 24 '16 at 16:46
-
2@cat: Really? The title is "How to send the ESC signal to vim when my esc key doesn't work?", the only tag is [tag:vim], and the problem described in the question is about escaping Vim's insertion mode. Here is the summarising part of the question: "Is there exist another key used to release the insert mode." If that's not specific to Vim and its insert mode, then I don't know what is! – Lightness Races in Orbit Dec 24 '16 at 16:54
-
2@LightnessRacesinOrbit Well, when I saw the title initially, it was "Another key used for Esc" and the question didn't look specific to
vim
at at all. sorry! ¯_(ツ)_/¯ – cat Dec 24 '16 at 17:06 -
So this was the only solution that worked for me on iterm2 on mac inside a tmux session. Hopefully that will help people stuck like I was.. nobody wants to have to kill a session off.. – John Hunt Feb 03 '22 at 09:09
-
-
If you want to be able to use a single key, as a pure *nix solution (without Vim mappings) you could define another key as Esc. Just like Emacs users remap CapsLock to Ctrl some Vim users (me included) remap CapsLock to Esc. This works for any *nix using X11.
Use xev -event keyboard
(and then press CapsLock) to get the keycode for the CapsLock key (for me it is keycode 66). Then you can use xmodmap
to remap the key:
xmodmap -e 'remove Lock = Caps_Lock' -e 'keycode 66 = Escape'
To get this at login you can add the xmodmap
expressions to ~/.Xmodmap
as follows:
remove Lock = Caps_Lock
keycode 66 = Escape
Although for the second part YMMV, since not all display managers run ~/.Xmodmap
. You may need to add xmodmap .Xmodmap
to .xinitrc
on some of them.

- 8,657
Existing solutions notwithstanding, the conventional solution in Vim is to remap keys in your .vimrc
configuration. In fact, many Vim users have an easier reachable key remapped to Esc. Popular choices are Ctrl+Enter, or jj, etc.
To enable this, just put something like the following into your .vimrc
and reload it/restart Vim:
" Shift-Enter
inoremap <S-CR> <Esc>
" Double-j
inoremap jj <Esc>

- 3,769
-
1Eyup, that's the Vim way. Another common way promoted by Learn Vim the Hard Way (book) is
inoremap jk <Esc>
– grochmal Dec 24 '16 at 16:37 -
This is a nice solution, but what is the problem to use only Ctrl+Enter+j? – Sandra Ross Dec 24 '16 at 16:38
-
@SandraRoss You can really use any key combination you fancy (though beware that some, e.g. Ctrl-Enter, don’t work on macOS). That said, Ctrl+Enter+j strikes me as more difficult to type, and I honestly don’t know whether you can even configure three-key combinations with two non-modifier keys (Enter, j) in Vim. – Konrad Rudolph Dec 24 '16 at 16:38
-
Ok, I undertand. In fact, Ctrl+Enter+jj doesn't work for me, because, indeed, I use macos X. At least, could you tell me what I have to enter for just Ctrl+j. – Sandra Ross Dec 24 '16 at 16:48
-
-
Great! It works well with
Ctrl+j
, and It's much more easier thanEsc
– Sandra Ross Dec 24 '16 at 17:13
Terminal emulators send an ESC code also when you press:
- Ctrl+[
- Ctrl+3 I like this one as you can use one hand only to press it.
- Alt followed by any other key. For example Alt+h,j,k,l will exit insert mode and move the cursor at the same time.

- 139
There's an issue in Siri that prevents some systems from reading ESC.
If that's the case, the following command should fix it:
killall Siri

- 453
Ctrl + F2
Is enabled by default. No need to configure any settings.
You will move to normal mode, where you can do :q! or :wq
.
[
– Thomas Dickey Dec 23 '16 at 20:51control+c
to exit insert mode. And the esc-not-working problem on macOS is probably caused by a frozen Siri, if not caused by hardware issue. Just go to Activity Monitor to force quit Siri, then you might solve the esc problem completely. ^_^ – Scott Yang Mar 02 '23 at 16:48