在 vim 的终端应用程序中使用 Shift 或 Command 映射功能键

发布于 2025-01-13 19:42:58 字数 406 浏览 2 评论 0 原文

我想映射功能键和 Shift/命令的组合,以便在 macOS 默认终端应用程序中切换 vim。

例如,

map <S-F5> [something Toggle]

or

map <C-S-F5> [something Toggle]

但是,在 Terminal 应用程序中,F5 (~F11) 和 Shift 键的组合简单地表示为波形符 (~),因此用 vim 打开的文本文件中的内容会变成大写。此外,Cmd+F5 是 VoiceOver 的快捷方式,这就是为什么我无法使用 进行切换。

如果有人有想法,请回答。

谢谢

I want to map the combination of functions keys and shift/command to make a toggle for vim in macOS default Terminal app.

For example,

map <S-F5> [something Toggle]

or

map <C-S-F5> [something Toggle]

However, in Terminal app, the combination of F5 (~F11) and shift key is simply indicated as tilde (~), so the contents in text files opened with vim become capitalized. In addition, Cmd+F5 is the shorcut for VoiceOver, that's why I cannot use <C-S-F5> for my toggle.

If anyone have an idea, please answer.

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

漫漫岁月 2025-01-20 19:42:58

一般来说,您应该假设 Vim 看到的是修改后的键的输出,而不是使用了什么修饰符或键。例如,在大多数情况下,当您按 Shift+A 时,Vim 会看到 A,而不是 A< /代码>。如果您的终端或操作系统或其他任何设置在您按 Shift+A 时发送 ),那么 Vim 将看到 ) 并且不知道关于你做了什么发送它)

该设计的一个结果是 a) 按键组合必须发送某物才能使其可映射,以及 b) 所讨论的“某物”与其他组合发送的其他“某物”是可区分的。

实际上,TUI Vim 无法区分 ,它们都发送相同的字符序列。

FWIW,Ctrl 的表示法。 Cmd 的表示法是 但 TUI Vim 永远不会收到 Cmd 所以你无论如何也不能使用它。

所以你基本上可以忘记:

  • Shift+功能键、
  • Ctrl+功能键、
  • Ctrl+Shift+功能键、
  • 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 press Shift+A, not <Shift> and A. If your terminal or OS or whatever is set up to send ) when you press Shift+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 for Ctrl. The notation for Cmd is <D- but TUI Vim never receives Cmd so you can't use it anyway.

So you can basically forget about:

  • Shift+Function key,
  • Ctrl+Function key,
  • Ctrl+Shift+Function key,
  • Cmd+anything.

NOTE: :help modifyOtherKeys has recently been added but it seemed to break more things than it fixed in my limited testing. YMMV.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文