2

I have a problem that is my backspace works in the terminal but not in Vim. It sent '^?' instead of '^H' and I have been trying to figure it out. I have checked my .bashrc and there is stty erase '^?' to remove the '^?' but somehow it is not working.

I have this in my .vimrc:

 set backspace=indent,eol,start
 set backspace=2
 fixdel

This is how I would normally fix it according to my knowledge but it doesn't work in this case. I'm using xterm on Arch Linux server if that helps, I know there is a bug for xterm but I don't think that's the case. It works in Unix command but not Vim, so just the Vim that isn't working.

Any help is greatly appreciated.

Edit: Um to clarify, I just want my backspace to delete things. My backspace doesn't delete things right now and it is giving me ^? instead of deleting. The deleting is the same as any other system that is ^H but I want to make backspace to send ^H which is delete not ^?. So instead of having to type ^H to delete, I want to do it with backspace, on MobaXterm there is a function that makes backspace to send ^H. But how do I do that on SSH?

Thanks

Anthony Kung
  • 1,025
  • 3
  • 12
  • 22
  • Is it(backspace) not working in "insert" mode of vi too? – RavinderSingh13 Jan 16 '19 at 03:15
  • If you go into your unix shell and type Control-V backspace, you'll see that your backspace key is really generating the ^? character there, too - it's just that the shell is expecting it. Do you really need the backspace to send ^H, and thus also have to change the stty settings for your shell, or do you just want to teach vim to use ^? as backspace? – Ed Grimm Jan 16 '19 at 03:29
  • Archlinux sets system-wide defaults in `/usr/share/vim/vimfiles/archlinux.vim` and already has `set backspace=indent,eol,start`. You can further control system wide user configuration in `/etc/vimrc`. – David C. Rankin Jan 16 '19 at 05:00
  • Yes, backspace is not working in insert mode. I just want backspace to delete the characters as it should in anywhere else and delete in Vim is ^H but backspace in ASCII is ^? I believed so instead of sending ^? for backspace I would like it to delete which is ^H. I had already set up my .vimrc with that code. – Anthony Kung Jan 16 '19 at 07:23

1 Answers1

1

There's two ways to go. To the left, you see the control-H character you crave. The path that way seems clear, just a little

echo xterm.vt100.backarrowKey: true >> ~/.Xresources; xrdb ~/.Xresources

followed by either restarting all of your xterms, or pressing control and your primary mouse button on each window to bring up the menu that lets you change it per window; the menu item itself is the second one in the third section, it's right under the 8-bit controls option. That way seems to be viable. Except, beware, there's a trap door under the control-H itself, as then backspace stops working properly everywhere else except bash itself. Of course, you have part of the way out of that maze already, with your stty fu. But I kind of recall running into all sorts of other issues with that path. One of them being that the Linux console also uses ^? instead of ^H, and that's not so easy to change.

Or, the other way is to get vim to be able to do what you're trying for, using ^?. Which I think is just

:map ^V^? x

Note that I mean control-V backspace, not caret V caret question. You would also want to add this to your ~/.vimrc if that does what you need. That having been said, you didn't say exactly where in vim isn't working quite right, so it's possible you're needing a different tweak instead.

phd
  • 82,685
  • 13
  • 120
  • 165
Ed Grimm
  • 548
  • 5
  • 13
  • Unfortunately, this doesn't work for me. I have tried mapping the backspace, now it works in insert mode but not command mode. I am puzzled by this... – Anthony Kung Jan 17 '19 at 04:32
  • You're in a tiny little maze of mapping tables, all different. Maybe `:help map-overview` will be helpful. Unfortunately, my torch has gone out, so I dare not move for the moment, lest I be eaten by a grue. Hopefully I'll be able to find another torch ere tomorrow eve. For what it's worth, I think I last dealt with this sort of issue for my own usage back when I still hadn't given up on adventure. Trying to remember this mess has dredged up some interesting memories. – Ed Grimm Jan 17 '19 at 05:06