在 Vim 中映射 Esc 键 [英] Map Esc key in Vim

查看:136
本文介绍了在 Vim 中映射 Esc 键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Vim 的初学者.我讨厌按 Esc 键,这在我的 T61 上有点远.以返回命令模式.如何将其映射到 F4?

I'm a beginning Vim user. I hate pressing the Esc key, which is a little far on my T61. In order to return to command mode. How do I map it to F4?

推荐答案

对于单个会话,您只需准确输入以下按键:

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

esc:imap空格<f4>空格<esc>输入

esc 键确保您处于命令模式,冒号开始一行命令,imap 将 F4 键映射到 ESCAPE.

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

但是,如果您希望在每个会话中都保留它,则需要将其放入 Vim 启动文件中.

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

它的位置因您的环境而异(对于我的 Linux 机器,gvim 位于 $HOME/.gvimrc,vim 位于 $HOME/.vimrc).您需要找到它并添加以下行:

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>

你可以使用的一个技巧是启动一个裸 Vim 会话(vim 不带参数)然后输入

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.

还有,

:echo $HOME

应该告诉你它在 Windows 下的位置.

should tell you the location of it under Windows.

这篇关于在 Vim 中映射 Esc 键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆