是否可以将<C - ;>映射到:在vim中?

Sła*_*osz 12 vim

我使用capslock作为控件,因此使用它更自然,:noremap <C-;> :不起作用.是否可以在vim中进行此类映射?

mMo*_*ntu 9

Vim FAQ(也可通过这个漂亮的插件获得):

20.4. I am not able to create a mapping for the <xxx> key. What is wrong?

1) First make sure, the key is passed correctly to Vim. To determine if
   this is the case, put Vim in Insert mode and then hit Ctrl-V (or
   Ctrl-Q if your Ctrl-V is remapped to the paste operation (e.g. on
   Windows if you are using the mswin.vim script file) followed by your
   key.

   If nothing appears in the buffer (and assuming that you have
   'showcmd' on, ^V remains displayed near the bottom right of the Vim
   screen), then Vim doesn't get your key correctly and there is nothing
   to be done, other than selecting a different key for your mapping or
   using GVim, which should recognise the key correctly.
Run Code Online (Sandbox Code Playgroud)

试试上面的内容<C-;>表明它没有被vim/gvim捕获......

  • 一个补充:对于所有ascii字符`<C- {c}>`的代码点等于`char2nr({c}) - 0x40`,因此`<C- {c}>`用于代码点少于`0x40`不能用vim的字节队列格式表示,因此vim无法识别.可以用这种格式表示的最后一个字符是"0x5F":"0x5F-0x40 = 0x1F","0x1F + 0x01 = 0x20","0x20"是一个空格.所以vim只识别了'0x20`(32)`<C -...>`组合.如果有人更改了使用的字节队列格式,它将来可能会发生变化. (8认同)