post Category: Code — Chris @ 2:19 am — post

This is easily fixed. Enter the below in ~/.vimrc

” Ensure correct delete/backspace mapping, even from ssh
set t_kb=^?
set t_kD=^H
set backspace=indent,eol,start

updated: thanks to Stuart.

Horaayy..there are 5 comment(s) for me so far ;)

#1

Or, for the current way to perform the fourth action in versions of vim from 5.5 onwards:

:set backspace=indent,eol,start

(Note that this allows backspacing over autoindents and line breaks, allows deletion from before the point where the current insertion commenced)

… so it’s not required to get backspace/delete working properly - but it’s certainly nice to have!

stuart wrote on October 29, 2006 - 12:02 am
#2

… and actually, it’s the wrong way around!

Firstly, the first line makes ^? and ^H indistinguishable, so there’s no way to tell backspace (delete-left) from delete (delete-right). This is obviously wrong, and so should be omitted.

The second line maps the backspace function to delete, the third line maps the delete function to backspace!

So the correct entries in .vimrc are:

” Ensure correct delete/backspace mapping, even from ssh
set t_kb=^?
set t_kD=^H
set backspace=indent,eol,start

… noting that “^?” is input by typing ctrl+v, then backspace, and “^H” from ctrl+v then delete. Depending on the language settings and unicode mode on either end of an ssh connection, this may not appear as ^H, you may see something similar to “^[[3~”.

Yay to fully unicode OSs <sigh>

(Everyone should try Plan 9 at least once ;)

stuart wrote on October 29, 2006 - 12:17 am
#3

Stuart, good comments as always! ;) However, the above settings work 100% for me in both SSH and local xterm’s.

Chris wrote on October 29, 2006 - 12:27 am
#4

This didn’t work for me. I’ve still got a forward delete for a backspace key. What gives?

amanda wrote on February 25, 2007 - 5:47 am
#5

Thank you so much! I’ve been sitting here for a good 20mins trying to figure out what was going on, as opposed to starting my assignment.

Thanks again. Jerome

Jerome wrote on March 5, 2007 - 12:00 pm
You can leave a response, or trackback from your own site.

Write Your Comment

Comment Guidelines: Basic XHTML is allowed (a href, strong, em, code). All line breaks and paragraphs will be generated automatically.

You should have a name, right? 
Your email address, I promised I won't tell it to anyone. 
If you have a web site or blog, you can type the URL right here. 
This is where you type your comments. 
Remember my information for the next time I visit.
 

This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)

You must read and type the 4 chars within 0..9 and A..F, and submit the form.

  

Oh no, I cannot read this. Please, generate a