vim <C-S-Key> 映射

标签 vim mapping

我正在使用 Cygwin/Mintty/Vim 工作。

<C-v>我看到<C-S-c>编码为<83> 。这意味着 vim 可以读取它,并且我可以使用 map 命令映射它。

不幸的是,如果我尝试:

 :inoremap <C-S-c> foobar

这不起作用...

我怎样才能让它工作以及为什么 vim 拒绝映射 Unicode 按键?

同样的问题<C-S-F1> 。如果我执行这个命令:

 :inoremap <C-S-F1> foobar

我会得到这样的东西:

[20;5~[20;5~[20;5~[20;5~[20;5~[20;5~[20;5~[20;5~[20;5~[20;5~[20;5~[20;5~[20;5~[20;5~[20;5~[20;5~[20;5~[20;5~[20;5~[20;5~[20;5~[20;5~[20;5~[20;5~[20;5~[20;5~[20;5~[20;5~[20;5~[20;5~[20;5~

哪里F1[1;5PF9[20;5~

最佳答案

Vim 显然不支持涉及 Control ( <C-…> ) 的奇异组合键。其中包括 F1 - 尽管您的其他尝试映射 ShiftC 受支持(并且相当于仅使用 < kbd>C)。来自 Tony Mechelyncka forum thread “Mapping ctrl-; (ctrl semicolon)” 上的帖子:

The only printable keys which can reliably be used with Ctrl, with predictable results, in cooked mode on any OS, are those defined by ASCII, and that means the following AND NO OTHERS:

  • ASCII characters 0x40 to 0x5F (i.e. uppercase A to Z, plus the six nonalpha characters at-sign, left-bracket, slash, right-bracket, [caret] and underscore), where Ctrl subtracts 0x40, thus mapping them to 0x00 to 0x1F respectively. This explains why Ctrl-[ means Esc, Ctrl-I means Tab, Ctrl-M means Enter, etc.
  • Lowercase letters, whose Ctrl counterpart is the same as for the corresponding uppercase (thus Ctrl+letter and Ctrl+Shift+letter are always the same for a given letter)
  • In addition, Ctrl-? is mapped to 0x7F (DEL).

Vim may or may not see other Ctrl-combinations, but that depends on the terminal, and in most cases it won't see them, or confuse them with something else such as the same key without Ctrl.

至于你的 <C-S-c> 映射,我不完全确定为什么你可以看到 <C-S-c> <C-v> 但你无法映射它。当我在 MacVim(一个 GUI)中测试时,当我尝试 ^C 时,我得到了字符 <C-v><C-S-c> ,并且 :inoremap <C-S-c> foobar 可以工作。当我在 OS X 的终端中进行测试时,终端会吞下 <C-v>:inoremap 的击键和蜂鸣声。在这两种情况下, <C-v> 的行为与 :inoremap 的行为一致,所以我不知道为什么您会看到这种差异。

关于vim <C-S-Key> 映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26334111/

相关文章:

python - Vim、omnicomplete 和 python 文档

vim - 设置 mintty 的窗口标题

grails - 静态映射关闭中的Grails “duplicate field name”错误

python - pandas.cut 带有枚举的 bin

c# - 如何将常量和类属性值映射到 Dictionary<int, object>?

c# - 如何将一个列表映射到另一个列表,就像函数式编程语言一样?

windows - 让 Vim 在 Windows 下与 Go 一起工作

vim - 对齐最长的单词

C++ 在 1D 数组中表示 3D 数组

vim - 如何忽略 Vim 单词完成的某些文件?