vim backspace leaves ^?

vim set backspace
map backspace vim
make backspace work vim
backspace inserts ^ in vim
mac vim backspace not working
vimrc
can t backspace in insert mode vim
vim delete in insert mode

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

^? 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)

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.

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 (^?)

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

Backspace and delete problems | Vim Tips Wiki, Need to reword and clarify what each is talking about. Backspace key won't move from current line. Backspace works in Insert mode (  vim backspace leaves ^? Related. 1237. Tab key == 4 spaces and auto-indent after curly braces in Vim. 252. Autocompletion in Vim. 65. Mac terminal Vim will only use

From the vim wiki Backspace_and_delete_problems, I went on to read :help :fixdel it suggests this:

if &term == "termname"
  set t_kb=^V<BS>
  fixdel
endif

Where "^V" is CTRL-V and "" is the backspace key (don't type four characters!). Replace "termname" with your terminal name.

For me the fixdel makes the backspace work like delete. My first mistake was also doing the CTRL-V backspace in gvim, do on the system that you can not get the key to work properly so it pastes the backspace key that the problematic session sees.

I now have in my .vimrc:

if &term == "xterm-256color"
  set t_kb=^?
endif

backspace in insert mode not erasing characters, Sometimes the vi command is an alias for vim and when called as vi enables its vi-mode. Even in traditional mode backspace is deleting the character, but does  How to configure following keys in vim? Backspace key to delete a character backwards. Delete key to delete a character forwards. After reading some posts, I got to know that only one of those ca

Try adding:

noremap! <C-?> <C-h>

to your ~/.vimrc.

This maps C-? to backspace, and worked for me.

Fix Backspace in VIM :: Chris Jean, Then hit enter. Now try to use your backspace key while in insert mode. Once you confirmed that this works for you, add this option to your .vimrc file  I have a Ubuntu 12.04 OS. I installed vi and vim, but the backspace doesn't work properly. It is doing the same thing that delete key do. I am expecting the backspace key to delete a character backwards, but it deletes forwards.

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.

vi or vim Using Backspace Inserts ^? – Alvin Bunk, Introduction In my day to day job I use Linux hosts and I always use the vim editor (In most Linux distros, vi is an alias for vim). When using  set backspace=indent,eol,start " more powerful backspacing. Also, starting from Vim 8.0 if no user vimrc file is found, Vim will set backspace to this value by loading the defaults.vim script. improve this answer. edited Sep 21 '18 at 8:42. answered Jul 19 '12 at 11:59. 220 silver badges. 291 bronze badges. it's still doesn't work for me =/ i

backspace not working, even after attempted fix, Vim seems to be confused about what your terminal sends as the erase character​. As this varies between ^? ( Ctrl+? , or DEL for "delete") and ^H ( Ctrl+H or BS  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.

Vi-mode: Backspace not working as expected in insert mode · Issue , In vi-mode backspace doesn't currently delete characters that were typed before switching E.g.: Type something Leave insert mode/enter normal mode Enter insert mode again If you have this problem in vim, you can add. The “backspace” escape character '\b': unexpected behavior? jQuery: keyPress Backspace won't fire? how to check for the “backspace” character in C ; Configure eclipse so that backspace unindents ; How can I fix my delete key in VIM over ssh?(Mac OS X)

Backspace in insert mode in vi doesn't erase the character, i f o o Backspace Esc :q Quits (Exits) if you've made no changes :q! Install the full vim package to get the backspace and arrow key  Sometimes the vi command is an alias for vim and when called as vi enables its vi-mode. Even in traditional mode backspace is deleting the character, but does not display it as deleted immediately. (After pressing ESC the characters are gone.)

Using the VI Editor, Use Backspace to delete to the left of the cursor. If you need i = insert before (​new text will appear before current cursor position) -- leaves you in insert mode

Comments
  • Please check the link bellow to help debug your problem: > vim.wikia.com/wiki/Backspace_and_delete_problems EDIT: i found what it seems like a similar problem with the one described by you: > lj4newbies.blogspot.com/2007/05/…
  • Sorry I tried that but didn't work!
  • i've updated my post with some new hints, please revise them
  • which terminal/OS do you use?
  • In cat -v, what is printed when you hit Delete and Backspaces keys? What is your output from stty -a?
  • You are correct. It is the stty in my bashrc file which screwed things up. Thanks for clarifying.
  • Happened to a few folks here using putty on unix (not linux) in putty it's an easy fix pref->terminal->keyboard->backspace change to ^H
  • What does stty erase ^? 2>/dev/null do?
  • I don't have any stty in my vim.
  • I want to add that if you don't have 'stty' on your .bashrc file and you're seeing this issue... then add 'stty' to your .bashrc file and this issue will go away. stty erase '^?'
  • Me too... using exceed ---> SSH ---> RHEL > ksh > tmux > vim
  • I couldn't figure out how to get the ^H character to work so instead I did: imap ^? <BS> in the .vimrc file and it works fine now. cmap is also necessary for command and searching.
  • horta's modification worked for me, while ^H did not: imap ^? <BS>
  • Took me forever trying out other solutions but this did it for me on a mac, cheers!
  • This worked for me as well. Simple and to the point. The only thing is, I put my changes in the global vim configuration under /etc/vimrc (edited with sudo)