Map Esc key in Vim

怎甘沉沦 提交于 2019-11-30 09:26:18

For a single session, you could just enter the following keystrokes exactly:

esc:imapspace<f4>space<esc>enter

The esc key ensures that you're in command mode, colon starts a line command, and the imap maps the F4 key to ESCAPE.

However, if you want this retained for every session, you'll need to put in in your Vim start-up file.

The location of this varies depending on your environment (for my Linux box, it's at $HOME/.gvimrc for gvim, $HOME/.vimrc for vim). You'll need to find it and add the line:

imap <f4> <esc>

One trick you can use is to start a naked Vim session (vim without an argument) then enter

:e $MYVIMRC

which will open up your current start-up file.

Also,

:echo $HOME

should tell you the location of it under Windows.

Just like many Emacs users rebind their "Caps Lock" key to "Control", vimmers rebind their "Caps Lock" to "Escape".

...At least I do. And it works wonders.

Another way to exit insert mode is to use Ctrl+C. Not sure whether that helps in your situation though.

Try home row:

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