Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

The Backspace key is not working as expected in vim and also in vi. It is working as the Delete key, and Delete key is deleting the char, but instead something wierd happens. But, for now, I am trying to get the Backspace key working.

I tried few solution by googling and searching unix.se, but none helped. I tried adding

:map~ ^? ^H

to .exrc file. Also tried adding following function from this link, later mapping the correct key-sequence as given, but even that didn't help solve the issue.

func Backspace()
  if col('.') == 1
    if line('.')  != 1
      return  "\<ESC>kA\<Del>"
    else
      return ""
    endif
  else
    return "\<Left>\<Del>"
  endif
endfunc

vim details

VIM - Vi IMproved 7.0 (2006 May 7, compiled Jun 12 2009 07:09:20)

Machine

$ cat /etc/*release
Red Hat Enterprise Linux Server release 5.5 (Tikanga)

Note:

  1. I connect to a remote unix machine using putty connection manager.
  2. Shift+Backspace works as normal Backspace key works i.e. delete a character to the left.
share|improve this question
1  
Is it in command mode or in insert mode? At times, it helps configuring PuTTY as follows: "Keyboard" tab: Function keys set to "Linux". "Connection data" tab: "Terminal-type string" set to linux –  Gert van den Berg Jan 2 '13 at 12:28
add comment

3 Answers 3

up vote 0 down vote accepted

In addition to Gert's comment about PuTTY, the third post in this thread also has a note about PuTTY settings:

Under the Terminal -> Keyboard section, there is block labelled "change the sequences sent by:" - the 1st one is Backspace. It should be either Control-H or Control-?. Change it to the opposite of what is currently set and it should work.

share|improve this answer
add comment

Have you tried setting the backspace mode? Have a look at :help bs and try the following:

set bs=indent,eol,start

There's also a note in that help section about using :fixdel "if your <BS> or <Del> key does not do what you want".

You may also need to set "no compatible" (WRT to vi), so :set nocp.

share|improve this answer
    
Yup tried that also. backspace still working as delete key. –  mtk Jan 2 '13 at 12:50
1  
Hmm, how about with :set nocp too? –  goldilocks Jan 2 '13 at 12:54
add comment

goldilocks answer helped, and after setting the config as he showed, I followed the following steps that solved the problem -

Setting the TERM to xterm by

$ TERM=xterm; export TERM

And later adding the following to .bashrc file.

stty erase ^H
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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