在 vim 的终端应用程序中使用 Shift 或 Command 映射功能键
我想映射功能键和 Shift/命令的组合,以便在 macOS 默认终端应用程序中切换 vim。
例如,
map <S-F5> [something Toggle]
or
map <C-S-F5> [something Toggle]
但是,在 Terminal 应用程序中,F5 (~F11) 和 Shift 键的组合简单地表示为波形符 (~),因此用 vim 打开的文本文件中的内容会变成大写。此外,Cmd+F5
是 VoiceOver 的快捷方式,这就是为什么我无法使用
进行切换。
如果有人有想法,请回答。
谢谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一般来说,您应该假设 Vim 看到的是修改后的键的输出,而不是使用了什么修饰符或键。例如,在大多数情况下,当您按
Shift+A
时,Vim 会看到A
,而不是
和A< /代码>。如果您的终端或操作系统或其他任何设置在您按
Shift+A
时发送)
,那么 Vim 将看到)
并且不知道关于你做了什么发送它)
。该设计的一个结果是 a) 按键组合必须发送某物才能使其可映射,以及 b) 所讨论的“某物”与其他组合发送的其他“某物”是可区分的。
实际上,TUI Vim 无法区分
、
和
,它们都发送相同的字符序列。FWIW, 是 但 TUI Vim 永远不会收到
Ctrl
的表示法。Cmd
的表示法是Cmd
所以你无论如何也不能使用它。所以你基本上可以忘记:
注意:
:help modifyOtherKeys
最近被添加,但它似乎破坏了比我有限的测试中修复的更多的东西。 YMMV。In general, you should assume that Vim sees the output of the modified keys, not what modifier or key was used. For example, in most context, Vim would see
A
when you pressShift+A
, not<Shift>
andA
. If your terminal or OS or whatever is set up to send)
when you pressShift+A
, then Vim will see)
and have no idea about what you did to send it that)
.One consequence of that design is a) that a key combo has to send something for it to be mappable, and b) that the "something" in question is distinguishable from other "somethings" sent by other combos.
In practice, TUI Vim is unable to distinguish between
<F5>
,<S-F5>
, and<C-S-F5>
, which all send the same character sequence.FWIW,
<C-
is the notation forCtrl
. The notation forCmd
is<D-
but TUI Vim never receivesCmd
so you can't use it anyway.So you can basically forget about:
NOTE:
:help modifyOtherKeys
has recently been added but it seemed to break more things than it fixed in my limited testing. YMMV.