History
Article Edit this page Discussion

Fix Backspace

From Vim Tips Wiki

Jump to: navigation, search

Proposed new tip

Please do not use this page to discuss whether to keep this tip, and do not edit the talk (discussion) page.

All discussion should take place on the proposed new tips page, where we will decide whether to keep this as a new tip, or whether to merge it into an existing tip. However, if you have a suggestion on the content, please edit the tip or add your suggestion to the Comments section at the bottom.

Created: February 16, 2008 Complexity: basic Author: Metacosm Version: 7.0


Backspace works, but won't go up or down a line.

set backspace=2 " make backspace work normal (non-vi style)
set whichwrap+=<,>,h,l  " backspace and cursor keys wrap to next/prev lines

Backspace just puts weird characters in my file.

This is all from :help :fixdel (Vim's help is amazing).

:fix[del]              Set the value of 't_kD':
                                't_kb' is     't_kD' becomes
                                  CTRL-?        CTRL-H
                                not CTRL-?      CTRL-?

                        (CTRL-? is 0177 octal, 0x7f hex) {not in Vi}

                        If your delete key terminal code is wrong, but the
                        code for backspace is alright, you can put this in
                        your .vimrc:
                                :fixdel
                        This works no matter what the actual code for
                        backspace is.

                        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.

                        If your <Delete> key sends a strange key sequence (not
                        CTRL-? or CTRL-H) you cannot use ":fixdel". Then use:
                                :if &term == "termname"
                                :  set t_kD=^V<Delete>
                                :endif
                        Where "^V" is CTRL-V and "<Delete>" is the delete key
                        (don't type eight characters!). Replace "termname"
                        with your terminal name.

                                                        *Linux-backspace*
                        Note about Linux: By default the backspace key
                        produces CTRL-?, which is wrong. You can fix it by
                        putting this line in your rc.local:
                                echo "keycode 14 = BackSpace" | loadkeys

                                                        *NetBSD-backspace*
                        Note about NetBSD: If your backspace doesn't produce
                        the right code, try this:
                                xmodmap -e "keycode 22 = BackSpace"
                        If this works, add this in your .Xmodmap file:
                                keysym 22 = BackSpace
                        You need to restart for this to take effect.

There's also a bug in xterm (at least v224) that may bring other users into the same backspace problem. Here's the link: http://bugs.gentoo.org/show_bug.cgi?id=154090. The information there should be moved into this wiki, but that requires more effort than adding the link.

[edit] Comments

Rate this article:

Share this article:

Hubs Highlights International Sites Wikia messages
Entertainment
Gaming
Cartoons & Comics
Science Fiction
Hobbies
Sports
See all...
Grand Theft Auto
Doctor Who
Legend of Zelda Wiki
Terminator Wiki
Everquest II Wiki
Mystery Science Theater 3000
German
Spanish
Chinese
Japanese
More...
Wikia is hiring for several open positions
Send this article to a friend
"Fix Backspace"
 
 
Hi!

I thought you'd like this page from Wikia!

http://vim.wikia.com

Come check it out!
Send confirmation