vim 退格离开 ^? [英] vim backspace leaves ^?

查看:29
本文介绍了vim 退格离开 ^?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Vim 中,当我在 insert 模式下按 backspace 键时,它会留下 ^? 字符并且不会删除它的字符估计要删除.

In Vim, when I hit the backspace key in the insert mode, it leaves ^? character and does not delete the character it is suppose to delete.

我的 .vimrc

syntax on
set number
set expandtab
set incsearch
set nocompatible
set backspace=indent,eol,start
fixdel

这也发生在命令模式中.当我错误地输入 W 而不是 w 来保存时,我按下 backspace 键,它给了我以下信息:

This happens in the command mode too. When I wrongly type W instead of w to save, I press backspace key and it gives me the following:

:W^?

知道出了什么问题以及如何解决吗?!

Any idea on whats wrong and how to fix it?!

更新:在将这个问题发布到 SO 之前,我已经进行了基本的谷歌搜索,并尝试了搜索结果第一页的所有建议,但没有成功.

UPDATE: before posting this question to SO, I have done a basic google search and tried all the suggestion from the first page of search result but unsuccessful.

@strcat 我使用的是 vim 版本 7.0.237、KDE ​​控制台 1.6.4、Linux 2.6.18 x86_64 机器.

@strcat I'm using vim version 7.0.237, KDE console 1.6.4, Linux 2.6.18 x86_64 machine.

@graywh w.r.t cat -v,对于删除,我得到 ^[[3~ ,对于退格,我得到 ^?.

@graywh w.r.t cat -v, for delete, I get ^[[3~ and for backspace, I get ^?.

stty -a的输出如下

speed 38400 baud; rows 38; columns 194; line = 0;
intr = ^C; quit = ^\; erase = ^H; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O;
min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts -cdtrdsr
-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

推荐答案

^? 是删除字符;退格字符是 ^H.您的终端仅将其中一个识别为擦除",这由终端设置 stty 决定.(bash 和其他 shell 将其理解为一个问题,并且会做一些特殊的事情来识别两者)

^? is the delete character; the backspace character is ^H. Only one of these is recognized by your terminal as "erase", and this is determined by the terminal settings, stty. (bash and other shells understand this as a problem and do special things to recognize both)

如果您的终端模拟器(ssh、putty、xterm 等等)不同意您的终端设置,那么您会看到这种行为.通常默认情况下它是正确的,但很多时候人们会将 stty 命令放在他们的 .bashrc 中,这会破坏事情.

If your terminal emulator (ssh, putty, xterm, whatever) disagrees with your terminal settings, then you see this behavior. Usually it's right by default, but very often people will put stty commands in their .bashrc which breaks things.

你的 bashrc 中可能有类似 stty erase ^H 的东西.如果你这样做,摆脱它,或者改变你的终端设置让退格发送 ^H 而不是 DEL (^?)

You probably have something like stty erase ^H in your bashrc. If you do, get rid of it, or change your terminal settings to have backspace send ^H instead of DEL (^?)

您也可以使用 vim 映射来解决此问题,但这忽略了基本问题.

You can also fix this with vim mappings, but that's ignoring the basic problem.

这篇关于vim 退格离开 ^?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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