vim backspace leaves ^?

2019-01-16 05:40发布

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.

I have the following in my .vimrc

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

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?!

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 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, for delete, I get ^[[3~ and for backspace, I get ^?.

The output of stty -a is as follows

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

14条回答
戒情不戒烟
2楼-- · 2019-01-16 06:29

Try ctrl+del/ctrl+backspace or alt+del/alt+backspace, I cant remember which, but I think it will do the trick for you.

If that doesn't work try shift+backspace/del. I've ran into this problem before, there is a combo key that you can press to send the correct char code to do your deleting.

查看更多
仙女界的扛把子
3楼-- · 2019-01-16 06:32

Under FreeBSD with CSH you should replace this in your .cshrc:

bindkey "^W" backward-delete-word

With this :

bindkey "^?" backward-delete-word
查看更多
Fickle 薄情
4楼-- · 2019-01-16 06:42

This answer worked for me: http://vim.wikia.com/wiki/Backspace_and_delete_problems

Basically, putting set backspace=2 in .vimrc works.

查看更多
我命由我不由天
5楼-- · 2019-01-16 06:43

put stty erase ^? in your .bashrc

Run your .bashrc

run command: stty -a

speed 38400 baud; rows 48; columns 157; line = 0;
intr = ^C; quit = ^\; ***erase = ^?***; 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

Erase will be changed by now with new value ^? and your backspace shall work now.

查看更多
【Aperson】
6楼-- · 2019-01-16 06:44

On Mac, if you are using Terminal, go to Preferences -> Profiles -> Advanced, then select "Delete Sends Control-H"

查看更多
再贱就再见
7楼-- · 2019-01-16 06:45

If you are using KDE, I know that pain. This is the most comprehensive solution I have found so far http://www.yalla.nu/blog/post/86

查看更多
登录 后发表回答