How to map Ctrl+A and Ctrl+Shift+A differently?

前端 未结 6 522
别那么骄傲
别那么骄傲 2020-12-04 17:20

In a terminal, one cannot distinguish Ctrl+A and Ctrl+Shift+A as they both emit the same key code, so I can see why Vi

6条回答
  •  孤街浪徒
    2020-12-04 17:47

    Gvim doesn't do it because vim cannot do it (under normal circumstances). Sorry, but that's just how it is.


    However...

    Some terminals (e.g., xterm and iterm2) can be configured to send an arbitrary escape sequence for any combination of keys.

    For example, add the following to .Xresources for xterm to send [65;5u for CtrlShiftA. You can then map that in Vim to . (65 is the decimal Unicode value for shift-a and 5 is the bit for the ctrl modifier. The u in this case stands for "unicode".)

    ! .Xresources
    XTerm*vt100.translations: #override Ctrl ~Meta Shift a: string(0x1b) string("[65;5u")
    

    iTerm and [u]rxvt can also be configured to do this (examples not provided).

    More info: http://www.leonerd.org.uk/hacks/fixterms/

提交回复
热议问题