vim< C-S-Key>映射 [英] vim <C-S-Key> mapping

查看:62
本文介绍了vim< C-S-Key>映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与Cygwin/Mintty/Vim合作.

I am working with Cygwin/Mintty/Vim.

使用<C-v>时,我看到<C-S-c>被编码为<83>.这意味着vim可以读取它,我可以使用map命令对其进行映射.

With <C-v> I see that <C-S-c> is encoded <83>. This mean vim can read it and I can map it using the map command.

不幸的是,如果我尝试:

Unfortunately if I try:

 :inoremap <C-S-c> foobar

它不起作用...

我如何使它起作用,为什么vim拒绝映射Unicode按键?

How can I make it work and why vim refuses to map Unicode keystokes?

<C-S-F1>相同的问题.如果我执行此命令:

Same question for <C-S-F1>. If I execute this command:

 :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;5P并且F9[20;5~

推荐答案

Vim显然不支持涉及Control(<C-…>)的奇异组合键.其中包括 F1 -尽管支持您尝试的其他尝试映射 Shift C (并且等效于Control,仅 C ).摘自 Tony Mechelynck 的帖子论坛主题映射ctrl-; (ctrl分号)" :

Vim apparently does not support exotic key combinations involving Control (<C-…>). That includes F1 – though your other attempted mapping ShiftC is supported (and is equivalent to Control with just C). From a post by Tony Mechelynck on a forum thread "Mapping ctrl-; (ctrl semicolon)":

唯一可以与Ctrl, 在任何OS上的熟模式下,可预测的结果是由以下项定义的: ASCII,这意味着以下内容,并且没有其他内容:

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字符0x40至0x5F(即大写A至Z,再加上六个 符号处的非字母字符,左括号,斜杠,右括号, [插入符号]和下划线),其中Ctrl减去0x40,从而将它们映射 分别为0x00至0x1F.这解释了为什么Ctrl- [表示Esc,Ctrl-I 表示Tab,Ctrl-M表示Enter,等等.
  • 小写字母,其Ctrl对应于 相应的大写字母(因此Ctrl +字母和Ctrl + Shift +字母是 给定字母始终相同)
  • 此外,按Ctrl-吗?映射到0x7F(DEL).
  • 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可能会或可能不会看到其他Ctrl组合键,但这取决于 终端,在大多数情况下它不会看到它们,或将它们与 诸如没有Ctrl的相同键之类的东西.

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> rel ="nofollow"> <C-v> ,但您无法映射它.在MacVim(GUI)中进行测试时,尝试<C-v><C-S-c>时得到字符^C,并且:inoremap <C-S-c> foobar可以工作.当我在OS X的终端上进行测试时,终端会同时按下<C-v>:inoremap并同时击键并发出蜂鸣声.在这两种情况下,<C-v>的行为都与 :inoremap 一致是,所以我不知道您为什么会看到差异.

As for your <C-S-c> mapping, I’m not totally sure why you can see <C-S-c> with <C-v> but you can’t map it. When I test in MacVim (a GUI), I get the character ^C when I try <C-v><C-S-c>, and :inoremap <C-S-c> foobar works. When I test in OS X’s Terminal, the Terminal swallows the keystroke and beeps, with both <C-v> and :inoremap. In both cases, <C-v>’s behavior is consistent with :inoremap’s, so I don’t know why you are seeing the discrepancy.

这篇关于vim&lt; C-S-Key&gt;映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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