3

I'm having issues with my backspace in Vim, it is inserting ^? instead of deleting characters. I found this wonder bit of Vim documentation that will hopefully fix this problem.

        If the backspace key terminal code is wrong you can
        use this:
            :if &term == "termname"
            :  set t_kb=^V<BS>
            :  fixdel
            :endif
        Where "^V" is CTRL-V and "<BS>" is the backspace key
        (don't type four characters!).  Replace "termname"
        with your terminal name.

I am trying to add this bit of code to my .vimrc as the site suggests, but how do I know what my "terminal name" is?

2
  • 1
    At the command prompt, type echo $TERM
    – Kevin
    Commented Nov 5, 2013 at 2:55
  • 3
    in my experience, this is usually a problem with either your termcap or terminal emulator, not vim, and fixing it in the right place will resolve other headaches later. (also this sort of thing is guaranteed to bite you if you, say, SSH in from another machine... :))
    – Eevee
    Commented Nov 5, 2013 at 3:04

1 Answer 1

4

When you see &something in Vimscript, the something stands for one of Vim’s options (as are set with :set); &something refers to the current value or setting of something. You can use echo (or echom) to get the current setting of a given option. So in this case, you can get the terminal name — what is referred to in that code as &term — by starting Vim and running

:echom &term

and you can then replace termname in the code with the result.

(You can also use :set for this, as it turns out, by appending a ? to the option; running

:set term?

would print out the current setting of term, as e.g. term=xterm-color.)

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