我的 .vimrc 文件中有两行:
map <S-Enter> O<Esc>
map <CR> o<Esc>
第二行按预期工作,但第一行却没有。
这个想法是,如果我按下 Enter 键,那么 vim 应该在光标位置下方插入一个新行,并将光标向下移动到该行。如果我按 Shift-Enter,vim 应该在光标位置上方插入一个新行并将光标向上移动到该行。这种映射应该有效,因为首都O
正常模式下的 键将在光标所在行上方插入换行符,将光标置于该行的开头,然后将用户置于插入模式。首都O
其次是<Esc>
应该简单地将 vim 恢复到命令模式。
我已检查并资本O
按我的预期工作。那么为什么我的映射不起作用呢?我尝试过使用map <Shift-CR>
and map <Shift-Enter>
,但这些都不起作用。
EDIT结果它在 MacVim 中有效,但在 iTerm 中无效。如果有人能解释原因并提出解决方法,我将不胜感激。
Are you using console Vim? Some key combinations can only be mapped in GVIM. In all / most Linux terminals, Enter cannot be combined with Shift or Ctrl. Your mapping per se is correct, but you'd have to use a different LHS in the mapping.
Due to the way that the keyboard input is handled internally, some key combinations cannot be used even in GVIM. Some key combinations, like Ctrl + non-alphabetic cannot be mapped, and Ctrl + letter vs. Ctrl + Shift + letter cannot be distinguished. This is a known pain point, and the subject of various discussions on vim_dev and the #vim IRC channel.
有些人(首先是 Paul LeoNerd Evans)想要解决这个问题(即使是支持此功能的终端中的控制台 Vim),并提出了各种建议,cp。http://groups.google.com/group/vim_dev/browse_thread/thread/626e83fa4588b32a/bfbcb22f37a8a1f8 http://groups.google.com/group/vim_dev/browse_thread/thread/626e83fa4588b32a/bfbcb22f37a8a1f8
但截至今天,还没有补丁或志愿者出现,尽管许多人表示希望在未来的 Vim 8 主要版本中提供此功能。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)