Search code examples
emacscharacteremacs24keymappingbackspace

Backspace key deletes following character, not preceding character


first of all, sorry for my poor english..

I have installed emacs on linux mint, and i have set up my own config. Everything is all right except that the key backward delete the char on the right, (however it is supposed to delete the left one). how can i change this key comportement ? i have try to code with it, but its so hard to change the way i'm coding. I have look on the internet but didn't find anwser to this specific problem.

my backward key act like a the delete key ( and i'm working on mac air so i don't have the del key wich may cause the problem ? )

thanks.


Solution

  • Here's your answer: C-h r (which opens the Emacs manual), then g DEL Does Not Delete. That node of the manual speaks precisely to this well-known problem. The solution? Put this in your init file:

    (normal-erase-is-backspace-mode 0)
    

    How did I find that Emacs manual node?

    I used i, which searches the indexes of the current manual. And I use Icicles, which lets me use substring matching for completion (you can do that using vanilla Emacs also, but you need to configure it).

    So I just did i backspace S-TAB (S-TAB in Icicles performs apropos-style completion; TAB performs vanilla Emacs completion).

    C-h r i backspace S-TAB - that's all you need.

    That opens the Emacs manual and looks in the indexes for backspace as part of the index entry. So I saw these completion candidates (node names):

    <BACKSPACE> vs <DEL>
    <DEL> vs <BACKSPACE>
    c-electric-backspace
    C-S-backspace 
    normal-erase-is-backspace
    normal-erase-is-backspace-mode 
    

    Each of those entries except c-electric-backspace and C-S-backspace points, in fact, to the same node, DEL Does Not Delete. (You can use C-down repeatedly to visit each of the candidate nodes in turn, to see what they are.)


    Even in vanilla Emacs you have a way to apropos-search manuals: a in Info (i.e., in a manual) is command info-apropos. Try it: a backspace RET.

    However, it searches all of the manuals you have installed, for substring matches. And it takes quite a while to search all of the installed manuals.

    It produces (on my machine) an Info buffer that lists these search hits:

    Apropos Index
    *************
    
    Index entries that match `backspace':
    
    *Menu:
    
    * BACKSPACE (Info mode) [info]:          (info)Help-^L.
    * C-S-backspace [emacs]:                 (emacs)Killing by Lines.
    * c-electric-backspace [emacs]:          (emacs)Program Modes.
    * normal-erase-is-backspace-mode [emacs]: (emacs)DEL Does Not Delete.
    * normal-erase-is-backspace [emacs]:     (emacs)DEL Does Not Delete.
    * <BACKSPACE> vs <DEL> [emacs]:          (emacs)DEL Does Not Delete.
    * <DEL> vs <BACKSPACE> [emacs]:          (emacs)DEL Does Not Delete.
    * Backspace key invokes help [efaq]:     (efaq)Backspace invokes help.
    * Help invoked by Backspace [efaq]:      (efaq)Backspace invokes help.
    * backspace [elisp]:                     (elisp)Basic Char Syntax.
    * c-electric-backspace [ccmode]:         (ccmode)Hungry WS Deletion.
    * electric-backspace (c-) [ccmode]:      (ccmode)Hungry WS Deletion.
    * normal-erase-is-backspace-mode [ccmode]: (ccmode)Hungry WS Deletion.
    * backspace-function (c-) [ccmode]:      (ccmode)Hungry WS Deletion.
    * c-backspace-function [ccmode]:         (ccmode)Hungry WS Deletion.
    * <backspace> [ccmode]:                  (ccmode)Hungry WS Deletion.
    * C-c <backspace> [ccmode]:              (ccmode)Hungry WS Deletion.
    * C-c C-<backspace> [ccmode]:            (ccmode)Hungry WS Deletion.
    

    Only the ones for (emacs) are in the Emacs manual. You will notice, BTW, that the Emacs FAQ and the CC Mode manual both also document the same issue that you are seeing - it is a longstanding gotcha.