大多数情况下,我得到的是“^?”而不是退格操作

大多数情况下,我得到的是“^?”而不是退格操作

我发现很多时候如果我按下,BACKSPACE我只会在 GUI 终端应用程序中得到这个:

^?

我还发现,如果我按下INSERT该按钮,我会得到:

^[[2~

这变得相当烦人,因为它不但不会删除文本,还会添加更多文本。有什么办法可以解决这个问题吗?无论如何,为什么会发生这种情况?如果您需要我提供更多信息,请发表评论。

信息更新:

当我使用 ++ 启动终端CTRLALT按下TINSERT,我将获得上面所说的输出(大多数情况下),无论我输入什么,如果我按下 ,BACKSPACE我很可能只会得到它的符号,而不会真正删除任何内容。需要澄清的是,即使我没有在终端中执行任何先前的命令,也会发生这种情况,我只需输入一些内容然后按下BACKSPACE

该命令的输出stty -a是:

speed 38400 baud; rows 39; columns 72; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?;
eol2 = M-^?; swtch = M-^?; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon
-ixoff -iuclc ixany imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0
vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop
-echoprt echoctl echoke

我被要求将此文件的内容添加~/.inputrc到我的问题中,但该文件不存在,但是,另一个同名但位置不同的文件确实存在。因此,该文件的内容/etc/inputrc是:

# /etc/inputrc - global inputrc for libreadline
# See readline(3readline) and `info rluserman' for more information.

# Be 8 bit clean.
set input-meta on
set output-meta on

# To allow the use of 8bit-characters like the german umlauts, uncomment
# the line below. However this makes the meta key not work as a meta key,
# which is annoying to those which don't need to type in 8-bit characters.

# set convert-meta off

# try to enable the application keypad when it is called.  Some systems
# need this to enable the arrow keys.
# set enable-keypad on

# see /usr/share/doc/bash/inputrc.arrows for other codes of arrow keys

# do not bell on tab-completion
# set bell-style none
# set bell-style visible

# some defaults / modifications for the emacs mode
$if mode=emacs

# allow the use of the Home/End keys
"\e[1~": beginning-of-line
"\e[4~": end-of-line

# allow the use of the Delete/Insert keys
"\e[3~": delete-char
"\e[2~": quoted-insert

# mappings for "page up" and "page down" to step to the beginning/end
# of the history
# "\e[5~": beginning-of-history
# "\e[6~": end-of-history

# alternate mappings for "page up" and "page down" to search the history
# "\e[5~": history-search-backward
# "\e[6~": history-search-forward

# mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving
"\e[1;5C": forward-word
"\e[1;5D": backward-word
"\e[5C": forward-word
"\e[5D": backward-word
"\e\e[C": forward-word
"\e\e[D": backward-word

$if term=rxvt
"\e[7~": beginning-of-line
"\e[8~": end-of-line
"\eOc": forward-word
"\eOd": backward-word
$endif

# for non RH/Debian xterm, can't hurt for RH/Debian xterm
# "\eOH": beginning-of-line
# "\eOF": end-of-line

# for freebsd console
# "\e[H": beginning-of-line
# "\e[F": end-of-line

$endif

操作系统信息:

Description:    Ubuntu 15.04
Release:    15.04

答案1

您可以通过编辑终端配置文件来改变此行为。

  1. 在终端窗口中单击鼠标右键,然后选择个人资料 >> 个人资料偏好
  2. 或者从菜单中:编辑 >> 个人资料偏好设置
  3. 导航到兼容性选项卡并找到'退格键生成
  4. 选择 'ASCII 删除

如果这没有帮助,请参阅

相关内容