Score:1

For Nano, is it possible to include 'Backspace' in a custom keyboard shortcut binding in the .nanorc config file?

am flag

I am looking to create a keyboard shortcut for the Nano text editor to remove the word to the left of the cursor using the key combination Ctrl + Backspace.

Is the key backspace able to be included in a custom keyboard shortcut in a .nanorc file? Here is an example of what I am looking to do, which contains an invalid 'key' entry ^Backspace:

bind ^Backspace cutwordleft main

Here is some additional information from the nanorc v5 man page, wherein it mentions the 'Shift' key, but not 'Backspace':

The format of key should be one of:

^X where X is a Latin letter, or one of several ASCII characters (@, ], , ^, _), or the word "Space". Example: ^C.

M-X where X is any ASCII character except [, or the word "Space". Example: M-8.

Sh-M-X where X is a Latin letter. Example: Sh-M-U. By default, each Meta+letter keystroke does the same as the corresponding Shift+Meta+letter. But when any Shift+Meta bind is made, that will no longer be the case, for all letters.

FN where N is a numeric value from 1 to 24. Example: F10. (Often, F13 to F24 can be typed as F1 to F12 with Shift.)

Ins or Del.

Sadaharu Wakisaka avatar
pl flag
Welcome to AskUbuntu, the keys like Backspace or Cursor are often not understood correctly by system. When you use a remote server or so, these non-teletype characters are not printable. So that is a little useless to define such a shortcut. You can use `Shift-Ctrl-Del` for that purpose.
gridlocdev avatar
am flag
Thanks @SadaharuWakisaka, this is exactly what I was looking for!
muru avatar
us flag
@SadaharuWakisaka post an answer please - it looks like your comment solved the specific problem here
Sadaharu Wakisaka avatar
pl flag
@gridlocdev, that's good, happy to be useful.
Sadaharu Wakisaka avatar
pl flag
@muru, I thought that until you are writing an answer. Please take my comment in your answer. I am not interesting into earn my contribution but helping users and get helped myself. I'm old.
Score:1
us flag

Typically a terminal application doesn't receive a "Backspace" the way GUI application does. It receives a control character, which it will interpret like backspace. The terminal emulator, which is a GUI application, does the job of translating from the GUI Backspace to the appropriate control code, and this can be configured in the terminal emulator's settings. The usual control codes for Backspace can be ^H (the ASCII backspace character) or ^? (the ASCII Del character). Press CtrlV and then Backspace while in your shell to see which one it is.

gridlocdev avatar
am flag
It looks like for my shell (the default Gnome shell) the control code for 'Ctrl+Backspace' is `^H` and the one for regular backspace appears as `^?`! Would it be possible to modify my terminal settings to interpret the control code `^H` to press an unused key (such as any of the F13-F24 keys)? I could then probably add that new key to the .nanorc file accompanied by the command to run.
muru avatar
us flag
IIRC the GNOME Terminal configuration only has an option to change what gets sent for Backspace, but nothing for Ctrl-Backspace.
gridlocdev avatar
am flag
Darn, yeah I've just checked the gnome terminal preferences and it looks like that's the case. Thankfully, it looks like Nano has a default keybinding for 'Ctrl+Shift+Del' for the function I'm looking for so I think I'll use that instead!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.