本文介绍了如何获取Ctrl-Backspace来删除gnome-terminal中vim中的单词?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想按Ctrl-Backspace在vim插入模式下删除当前单词.在xterm中,我可以通过

:inoremap <C-H> <C-W>

但是在gnome-terminal中,我无法找到实现它的方法.

在vim插入模式下,如果我键入control-v然后按退格键,我在xterm中会得到^ H,而^?在gnome终端.不幸的是,

:inoremap <C-?> <C-W>

在gnome-terminal上不起作用;无论如何,控制退格键都会删除单个字符.

关于ASCII码:

Gnome-terminal允许您在编辑"->配置文件首选项"->兼容性"下更改退格字符.不幸的是,据我所知,没有任何选项有效:如果我尝试映射字符本身,则通过设置应用于Backspace的任何字符,例如

:inoremap <C-H> <C-W>

然后常规的退格键和控制退格键会擦除整个单词;如果我尝试映射控件加上该字符,例如

:inoremap <C-^H> <C-W>

然后常规的退格键和控制退格键只删除一个字符.

解决方案

gnome-terminal的libvte需要修补.

libvte已经有多个映射退格的选项,没有一个可以区分Ctrl-backspace.它需要一个可以执行此操作的选项,它可能遵循Linux控制台的行为(^?用于退格,^ H用于Ctrl-退格).请参见此gnome错误.


2015更新: 23c7cd0f99d504cbab06d4c27254d4a3 /p>

libvte 0.41.90、0.40.3及更高版本已修复.

I'd like Ctrl-Backspace to delete the current word in vim insert mode. From within xterm I can pull this off via

:inoremap <C-H> <C-W>

but in gnome-terminal I cannot figure out a way to make it happen.

When in vim insert mode, if I type control-v and then press backspace, I get ^H in xterm, and ^? in gnome-terminal. Unfortunately,

:inoremap <C-?> <C-W>

doesn't do the trick in gnome-terminal; control-backspace just erases a single character no matter what.

Regarding ASCII codes:

Gnome-terminal lets you change the backspace character under Edit -> Profile Preferences -> Compatibility. Unfortunately, no option works, as far as I can tell: whatever character I apply to Backspace via the settings, if I try mapping the character itself, like

:inoremap <C-H> <C-W>

then regular backspace and control-backspace both erase an entire word; and if I try mapping control plus that character, like

:inoremap <C-^H> <C-W>

then regular backspace and control-backspace just erase a single character.

gnome-terminal's libvte would need to be patched.

libvte already has several options to map backspace, none of which distinguish Ctrl-backspace. It needs an option that does, maybe one that follows the behaviour of the linux console (^? for backspace, ^H for Ctrl-backspace). See this gnome bug.


2015 update: this was fixed in 23c7cd0f99d504cbab06d4c27254d4f3e2807ba8.

libvte 0.41.90, 0.40.3 and newer have the fix.

这篇关于如何获取Ctrl-Backspace来删除gnome-terminal中vim中的单词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 22:40