1

In most text editors I use (Emacs, Nano, etc.), Ctrl+Left and Ctrl+Right allow me to skip forwards and backwards in the document one word at a time. Similarly, I can typically use Shift+Left and Shift+Right to select text to the left and right one character at a time, and Ctrl+Shift+Left and Ctrl+Shift+Right to select a word at a time, Shift+PgDn and Shift+PgUp to select a page at time, and so on. These movement and selection key combinations work regardless whether the editor is run as a native X11 application or in text mode in an X11 terminal emulator (e.g., running Emacs with emacs -nw in a Konsole or GNOME Terminal window).

However, when I switch to a real text-mode console (via Ctrl+Alt+F1 or by stopping my X server) and run the editors from there, I find these movement and selection key combinations no longer work. For example, Shift+Left and Ctrl+Left behave exactly the same as a bare Left. I don't think this is a problem with the editors themselves, because when I use bash to read these three keys (or key combinations) from the console, they all result in the same escape codes:

$ read
^[[C
$ read
^[[C
$ read
^[[C

The standard cut/copy/paste key combinations (Shift+Del, Ctrl+Ins, Shift+Ins) seem to have the same problem.

Is it possible to configure my text console so that using the Shift, Ctrl, and Shift+Ctrl modifiers on the usual movement and editing keys send the usual codes expected by editors like Nano and Emacs? All these key combinations worked fine in text mode back in the days of MS-DOS, so I'm a bit surprised that they don't work by default on my GNU/Linux machine. (If it makes any difference, I'm using openSUSE 13.2.)

  • when you say real text-mode console do you mean a command prompt in a terminal? The line editing features on a command line are part of the shell that is handling your command. you would use the bind command to get the behaviour you want – the_velour_fog Jul 8 '16 at 9:26
  • No, I mean editing text in an editor like Emacs, not editing a command line in a shell like bash. – Psychonaut Jul 8 '16 at 9:28
  • It's possible to modify the keymaps for the Linux virtual consoles, but the only examples which have been presented on this forum are trivial cases, showing how 1-2 keys can be setup. – Thomas Dickey Jul 8 '16 at 9:31
  • oh right, you mean when you run emac in a linux terminal? good question... maybe emacs is behaving differently because its detecting a different $TERM – the_velour_fog Jul 8 '16 at 9:32
  • Is there no existing mapping I could use that will make all the keys send the same codes they usually do in X? – Psychonaut Jul 8 '16 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.