2

In insert mode I want Backspace to delete the characters to the left of my cursor but it's acting just like Del and removing characters under my cursor. I saw somewhere I can use ctrl-k then a key to see what VIM thinks that key is. For Backspace it's returning <Del> and for Del it's returning <kDel>. How can I get my Backspace key to map to <BS> like it should be? In bash Backspace is operating normally without me making any special changes. In PuTTY Backspace is set to ^? not ctrl-h.

EDIT: I tested vim with the ctrl-h backspace setting and vim started working properly.. However I would prefer to leave that PuTTY setting alone unless someone can convince me switching to ctrl-h is what I should do, I don't know much about why there are different key codes for backspace and maybe I'd be less hesitant to switch the default PuTTY setting if I knew more.

  • 1
    What OS are you on? What terminal do you experience this problem in? Do you have nocompatible set? What does :se bs output? – DJMcMayhem Aug 2 '16 at 20:48
  • you can configure putty to send ^h instead of ^? – Christian Brabandt Aug 2 '16 at 21:25
  • @ChristianBrabandt switching that makes vim works, read my edit though. @DJMcMayhem nocompatible is not set, :se bs outputs backspace 2 I found this tldp.org/HOWTO/Keyboard-and-Console-HOWTO-5.html and if I run stty erase ^? the issue is fixed without changing PuTTY's settings. Is this approach considered bad or is it ok if this is the change I make? – ItsComcastic Aug 3 '16 at 13:29
  • You should change PUTTYs settings, I believe it's the only way. Also, this is unrelated to your question, but you should definitely :set nocompatible IMO vim is really a terrible editor until you change that setting. – DJMcMayhem Aug 3 '16 at 14:09
  • @ItsComcastic ctrl-h is the traditional key for backspace. So i would go with it. However, I have never encountered the problem in Putty, it has always worked correctly for me and I am using Putty extensively on many machines – Christian Brabandt Aug 3 '16 at 14:16
0

After reading through comments I came to the conclusion that this isn't an issue with vim that I can fix with .vimrc The server is expecting Backspace to be ctrl-h while PuTTY is set to ctrl-? by default.

After reading the information here, particularly this: If you do have the choice, we recommend configuring PuTTY to generate Control-? and configuring the server to expect it, because that allows applications such as emacs to use Control-H for help. I decided to change what the server is expecting instead of modifying PuTTy settings. (But the PuTTY setting could be changed instead)

To get the server to expect Backspace to be ctrl-? use the command stty erase ^? I added this to my .profile to have it automatically get set when I remote into the machine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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