The Vi editor was originally written on an ADM-3A terminal, which had the Escape key in place of the Tab key (compared to most modern keyboards). Many touch typists appreciate the fact that they can leave their hands on the keyboard home row while using Vim but the use of Esc makes it compulsory to leave the hands to press Esc. I am currently learning vim. Should remap Esc to somewhere else ? What is the most common remap for this case ? or should I leave the idea of remapping Esc and continue using it ? What do pro users of vim do ?
-
khachik: but ergonomics can be objective. Leaving the home row for some very common operation means bad ergonomics.– mike3996Dec 11, 2010 at 11:40
-
23why do you copy part of a text (vim.wikia.com/wiki/Avoid_the_escape_key) in which the answer is already given?– DaVinciDec 11, 2010 at 11:41
11 Answers
An alternative for the esc key is CTRL+[ combination.
(This is a standard in VIM, no need to remap anything).
I use this shortcut all the time instead of Esc.
Also I remapped my caps lock key to Ctrl, that way it is even easier to type.
-
15It's more "standard in terminals everywhere" than "standard in VIM". Traditionally, Ctrl-A produce ASCII code 1, Ctrl-B code 2, ... Ctrl-Z code 26, and by continuity, Ctrl-[ is mapped to ASCII code 27, ESC. Dec 11, 2010 at 11:59
-
1
-
@Pascal It's actually mapped in vim, so it works in gVim also. See :help ^[– SwissDec 11, 2010 at 19:34
-
2Why didn't anyone tell me Ctrl-[ is the same as escape, I feel like my finger has been making those long journeys to the escape key for nothing. I'm with you on the cap-lock, incidentally I picked up that habit from emacs, but considering how often I press Ctrl-c.– cdatedDec 14, 2010 at 5:25
-
@user537488: no it doesn't usually blink -- depends on how you mapped it. My gentoo linux doesn't recognize the caps lock (so it doesn't blink at all) nor does windows xp. Debian, on the other hand oddly blinks. The LED is controlled by the OS so if it sees a Ctrl or Esc instead of Caps lock, then it doesn't have to know anything else.– mike3996May 6, 2011 at 11:42
I have mapped Escape to otherwise unused Caps Lock. This is a common method to streamline vim's usage. This article has some alternative solutions, too. The same article links to tweaks to make the Escape-Capslock switch system-wide if you prefer.
-
4This is similar to the equivalent Emacs interface: Use caps-lock for ctrl. Anything else and you get crazy.– gimpfDec 11, 2010 at 11:42
-
2Remapping capslock to CTRL and using CTRL+[ instead of escape is the better way to go IMHO. It's almost as fine in VIM and even better for other programs.– sjasJul 10, 2012 at 10:48
-
@sjas, OTOH fewer programs support C-[ as Esc. (Of course talking about the X apps.) Sure, it is probably better to go that way.– mike3996Jul 10, 2012 at 10:50
-
-
1Haha, true but unintentionally. I was thinking of having a better reachable CTRL key you can use in other applications, too. Because IMHO you need CTRL way more often than ESC. :D– sjasJul 10, 2012 at 10:53
I have the key sequence jk
mapped to Esc
.
You might ask, so what happens when you come across a word with jk
. No problem. Type j
, wait for half a second and then type k
. Yes, that's non-ideal but the advantages of not having to move your hands of home row is much more.
I highly recommend jk
sequence as `Esc.
Other variations of the same idea are jj
- which in my humble opinion wont work for me. I use j
for moving down - as others.
-
1But that
jj
could be mapped to insert mode only. Though, if one spends a lot time in visual or command line mode, then a mapping such asjk
makes more sense! Hadn't thought of that.– mike3996Dec 11, 2010 at 13:54 -
2@progo, You're right.
jj
imap'd will work just fine. But I'm still leaning towardsjk
and this time my argument ( :) ) is thatjk
anyway is a NOOP (move down-move up) .. just likeEsc
Dec 13, 2010 at 2:42
I remap Esc to Caps systemwide.
In Linux:
Create a file ".Xmodmap" in your home directory, with the following content:
clear Lock
keysym Escape = Caps_Lock
keysym Caps_Lock = Escape
In Mac:
Download a program called "KeyRemap4MacBook" and remap tab to Esc.
Using other people's computer becomes a pain in the ass though. I'm such an environment tweaker that I look like my grandma on a standard setup :/
CtrlC also works for escape out of the box. I've got my Capslock key mapped to Ctrl as that's more useful to me in a number of situations.
-
Ctrl-C should be used with care as most plugins don't respond well when it is sent... sometimes this will even result in plugin crashes and bizarre behavior that is difficult to reproduce.– akdomJan 2, 2014 at 1:52
I have personally remapped <ESC>
to ii
.
i
to go in and ii
to go out of insert mode is easy to remember.
I mapped mine with ;;
and my right pinky finger is now aching, this is after a month of coding. I think it's a good decision to go with jj
or jk
.
I use Menu key instead of escape.
Details are here: How to map Menu key ("Application key") to Escape key in vim?
I rebinded capslock to control and right control to escape key, so pressing escape is just fine now.
imap jj <ESC>
Others like to map 'jk', or 'leader-j'. I don't use hjkl nearly as much as I should.
I've remapped it to my right ⌘ (mac keyboard) because it works always no matter what mode you're in or application.