4

When I mess up typing an uppercase letter, I usually hold Shift while pressing the Backspace. Instead of backspacing, it types ^? (to my frustration).

Google tells me that ^? is the "delete" character, but it has no effect from what I can see (I may be wrong).

I have seen stuff online for setting 'backspace' but none for shift-'backspace', so I'm lost unfortunately. I have also tried doing :inoremap <S-BS> <BS>, but that doesn't seem to be working either.

Please let me know

  • how to solve this; or,
  • why not to change this if it turns out to be something important; or,
  • why it can't be done for some reason.

Edit: update to responses to u/D. Ben Knoble and u/Ralf

  • OS: 18.04
  • Terminal: MobaXterm
  • Settings: result of $TERM is xterm
  • Vim Version: VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Apr 10 2018 21:31:58). Included patches: 1-1453
  • Typing <C-v><S-BS> gives '^?'
  • Typing <C-v><BS> gives '^H'
  • 1
    Please extend your question with information about operating system, terminal and Vim version. I have never heard something like this. – Ralf Jul 10 at 17:15
  • Welcome to Vi and Vim! As Ralf mentions, this is strange (although comprehensible) behavior—it likely has to do with the terminal emulator and the way vim interprets key sequences. The community needs more detail before it can help you answer your question. Relevant info to edit in would be: OS, terminal emulator (and settings: is it emulating xterm? other?), Vim version, the result of typing <C-v><S-BS> in a buffer (type the keys, not the literal text). – D. Ben Knoble Jul 10 at 17:30
  • To make it clear: "...never heard something like this": I never heard, that <BS> and <S-BS> produce different key codes. – Ralf Jul 10 at 17:45
3

Typically what you want is for backspace to send ^? and not ^H. (I need a citation, but this is typically how modern terminals work.)

It looks like MobaXterm has an option to have backspace send ^H, I imagine that option is currently set on your MobaXterm, perhaps start by trying to uncheck that option.

Then you should look into why Vim has an impression that ^? is not valid for backspace.

Perhaps start by checking what Vim thinks the escape sequences for the backspace key is:

:set t_kb

Normally, this should be ^?, if you have ^H, then check why that might be. Do you have a setting for t_kb in your .vimrc or another sourced file?

If that still doesn't solve it, you might want to explore these tips on backspace problems.


UPDATE: OP tracked it down to the version of xterm they were using. Setting t_kb explicitly in .vimrc produced a successful workaround for the issue.

Quoted by the OP, from the forums of the issue:

Good workaround if you can't/don't want to install a new version of xterm or whatever is to simply go into your .vimrc (in vim) and add the following:

set t_kb=^?

Note that you don't want to type '^' and then '?', but rather hit ; this should create a ^? symbol (or, if you have some similar bug, whatever symbol it thinks is backspace).

  • 1
    I am going to accept this answer as it helped lead me to a solution. t_kb was set to ^H, which was strange. After exploring the link you gave, the issue turned out to be with the xterm that I was using. Quoted from the forums of the issue: "Good workaround if you can't/don't want to install a new version of xterm or whatever is to simply go into your .vimrc (in vim) and add the following: set t_kb=^? Note that you don't want to type '^' and then '?', but rather hit <backspace>; this should create a ^? symbol (or, if you have some similar bug, whatever symbol it thinks is backspace)." – PoorProgrammer Jul 11 at 13:58
  • 1
    Thanks! I just updated the answer to include the exact workaround that solved it for you. – filbranden Jul 11 at 15:15

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.