When i hit backspace in insert mode in vim it forward-deletes, how can i make it backward-delete?

e.g.

I get (| is the cursor position):

aaa|bbb --3-backspace-hits--> aaa

I want:

aaa|bbb --3-backspace-hits--> bbb

Any suggestions would be helpful. Thanks!

link|improve this question
Looks like a terminal problem more than a vim problem. Care to detail how you're using vim ? is it gvim, vim under a TERM=vt100 terminal, vim under a TERM=xterm terminal, etc ? – Baramin Nov 28 '10 at 14:19
That's it. I am using xterm and now that I've tried it with konsole it is working fine. Do you have an idea what the problem might be? – user51891 Nov 28 '10 at 14:32
Try to type this in the xterm before running vim: stty erase ^H (and to do the ^H, you type Ctrl-V then the backspace key) and tell us how it went – Baramin Nov 28 '10 at 17:05
It's worth trying Ctrl-Backspace in vim too, too see if they're not inverted. – Baramin Nov 28 '10 at 17:06
feedback

3 Answers

up vote 0 down vote accepted

I can't verify this with my setup (I can't get my backspace key to misbehave in an xterm), but I think this behavior is controlled by the xterm controls backarrowKeyIsErase and/or backarrowKey. You can read about these in the xterm man page. You might try holding the Ctrl key while you press the left mouse button in your xterm window and checking or unchecking Backarrow Key (BS/DEL).

On a different system that the one I'm using now, I had this in my ~/.Xdefaults file:

xterm*backarrowKey: TRUE

so you might also try that. For new settings in a ~/.Xdefaults file to take effect, you'll have to either log out and back in, or execute this command at a shell prompt:

xrdb -override ~/.Xdefaults
link|improve this answer
feedback

I believe you are looking for Control + W to delete the word before the cursor.

For character level control, you use the "delete text of movement command": dh will (d)elete one character to the left. d2h will delete 2 characters to the left, etc...

link|improve this answer
I want the backspace button to do on insert mode what dh does on edit mode. Currently the backspace button delete forward not backwards as "dh". Do you see what i mean? – user51891 Nov 28 '10 at 13:34
feedback

'x' in vim deletes backwards..

link|improve this answer
It deletes forward here. – user51891 Nov 28 '10 at 13:11
'x' deletes the character under the cursor. The cursor is then under the next character. It's not supposed to delete backwards. – Baramin Nov 28 '10 at 14:19
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.