如何以不同方式映射Ctrl + A和Ctrl + Shift + A? [英] How to map Ctrl+A and Ctrl+Shift+A differently?

查看:83
本文介绍了如何以不同方式映射Ctrl + A和Ctrl + Shift + A?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在终端中,无法区分 Ctrl + A Ctrl + Shift + A ,因为它们都发出相同的密钥代码,所以我可以理解为什么Vim无法做到这一点.但是gVim作为X应用程序,可以区分 Ctrl + A Ctrl + Shift + A .有什么方法可以以不同的方式映射这两件事吗?

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 Vim can't do it. But gVim, being an X application, can differentiate Ctrl+A and Ctrl+Shift+A. Is there any way to map those two things differently?

对于初学者,我想执行以下操作:使从剪贴板粘贴"的工作方式类似于Gnome终端,同时保持 Ctrl + V 可见模式.

For starters, I'd like to do something like the following: Make "paste from clipboard" work like Gnome terminal, while keeping Ctrl+V to the visual mode.

:nmap <C-S-V> "+gP

推荐答案

Gvim不会这样做,因为vim不能这样做(在正常情况下).抱歉,就是这样.

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

但是...

可以将某些终端(例如xterm和iterm2)配置为发送任意组合键的任意转义序列.

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

例如,将以下内容添加到.Xresources中,以使xterm发送<Esc>[65;5u for Ctrl Shift A .然后,您可以将其在Vim中映射到<C-S-a>. (65是shift-a的十进制Unicode值,5是ctrl修饰符的位.在这种情况下,u表示"unicode".)

For example, add the following to .Xresources for xterm to send <Esc>[65;5u for CtrlShiftA. You can then map that in Vim to <C-S-a>. (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 <Key>a: string(0x1b) string("[65;5u")

iTerm和[u] rxvt也可以配置为执行此操作(未提供示例).

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

更多信息: http://www.leonerd.org.uk/hacks/fixterms/

这篇关于如何以不同方式映射Ctrl + A和Ctrl + Shift + A?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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