如何以不同的方式映射

如何以不同的方式映射

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

问题描述

在终端中,无法区分 + 和 ++ 因为它们都发出相同的密钥代码,所以我明白为什么 Vim 不能这样做.但是 gVim 作为 X 应用程序,可以区分 + 和 ++.有什么办法可以不同地映射这两件事吗?

In a terminal, one cannot distinguish + and ++ 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 + and ++. Is there any way to map those two things differently?

对于初学者,我想做如下操作:使从剪贴板粘贴"像 Gnome 终端一样工作,同时将 + 保持在视觉上模式.

For starters, I'd like to do something like the following: Make "paste from clipboard" work like Gnome terminal, while keeping + 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 for xterm 发送 [65;5u for .然后你可以在 Vim 中将它映射到 .(65 是 shift-a 的十进制 Unicode 值,5 是 ctrl 修饰符的位.在这种情况下,u 代表unicode".)

For example, add the following to .Xresources for xterm to send <Esc>[65;5u for . 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 00:10