In GNU nano 7.2 (the latest as of this posting, as far as I know), why does Ctrl+Delete delete entire words but not Ctrl+Backspace? How do we restore its correct functionality?

  • tal@lemmy.today
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    21 days ago

    I have GNU nano 8.4 on my system. Upon investigation, in default configuration:

    • Control-Backspace deletes the last character, same as Backspace.

    • Control-Delete reverse-deletes a word.

    • Alt-Backspace deletes the last word. This might be what you want.

    • Alt-Delete deletes the entire line.

    I think that it’s probably because absent some kind of unusual extension, terminals normally send 0x08, the Backspace character, same as Control-H, for Control-Backspace.

    On my system, in bash, using foot, Control-V Control-H shows ^H. So it’s sending ASCII 0x8, the Backspace character.

    Control-V Control-Backspace shows ^H. Ditto.

    Control-V Backspace shows ^?. It’s sending the Delete character, ASCII 0x7f.

    Control-V Del shows ^[[3~. It’s sending an escape sequence.

    Back in the day, some people had their terminals set to, when you hit Backspace, send either the Backspace character or the Delete character. Not a problem I’ve run into for some years, but I’d guess that nano probably has that behavior by default, treating both as hitting the Backspace key, so as not to break on systems like that.

    EDIT: I’d also add that Alt-Backspace (well, M-DEL in emacs parlance) is also what emacs uses for “delete word”, so a lot of software that uses readline, like bash, will also normally work that way out of box.