Why use Esc in vim? [closed]

≡放荡痞女 提交于 2019-12-20 18:01:14

问题


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 ?


回答1:


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.




回答2:


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.




回答3:


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.




回答4:


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 :/




回答5:


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.




回答6:


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.




回答7:


I use Menu key instead of escape.

Details are here: How to map Menu key ("Application key") to Escape key in vim?




回答8:


I have personally remapped <ESC> to ii.

ito go in and ii to go out of insert mode is easy to remember.




回答9:


I rebinded capslock to control and right control to escape key, so pressing escape is just fine now.




回答10:


imap jj <ESC>

Others like to map 'jk', or 'leader-j'. I don't use hjkl nearly as much as I should.




回答11:


I've remapped it to my right ⌘ (mac keyboard) because it works always no matter what mode you're in or application.



来源:https://stackoverflow.com/questions/4416512/why-use-esc-in-vim

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!