10

I’m stuck here:

Is it possible to bind one of <enter>, <backspace>, <up>, <down>, <left>, <right> together with control?

\C<foo> shows up as |foo> in the help and ^<up> isn’t bound.
'\C<foo>, '\C <foo>' don’t work, too (same with " instead).

<control> doesn’t exist.

You actually can get ^<foo> to show up in the help, but only if you map ^<foo>, which isn’t exactly what I want. ;)

5

First, you need to determine whether your terminal sends different escape sequences for these key combinations. Applications running in terminals get characters as input, not keys. Function keys are encoded as control characters or as escape sequences beginning with the escape character (which you can write as \e in a key binding).

To see the escape sequence sent by a key combination in a terminal, press Ctrl+V at a shell prompt, then press the key combination. For example, if I press Ctrl+V Ctrl+Left at a shell prompt, I see ^[O5D. ^[ is the escape character, so I would need to bind \eO5D in Mutt to make it react to Ctrl+Left:

bind editor \eO5D backward-word

Some terminals send the same escape sequence for the same key with different modifiers. If that's the case, you'll need to figure out how to change the terminal's behavior or switch to a different terminal.

| improve this answer | |
  • Sounds good, but it doesn’t work. \e is the escape key, not the escape character… – Profpatsch Feb 6 '13 at 12:23
  • @Profpatsch Weird, that binding works for me. I've been using Mutt 1.5 since about forever, maybe 1.4 works differently? Does it work if you use \e in a macro: macro editor \e[O5D \eb? – Gilles 'SO- stop being evil' Feb 6 '13 at 12:47
  • 1
    I’m on Terminator, when I hit Ctrl+Down I get ^[[1;5B, it doesn’t work with bind index \e[1;5B command and not with \e1;5B , too. Oh, I work with Mutt 1.5.21 (Arch. ;) – Profpatsch Feb 6 '13 at 13:48
  • 1
    @Profpatsch Ok, I can reproduce this. There seems to be a limitation to 5 characters: bind editor \e[1\;5 backward-word works for me (and inserts an extra D when I enter ESC [ 1 ; 5 D), but bind editor \e[1\;5D backward-word results in ESC [ 1 ; 5 D doing nothing. I see a limitation to 8 characters in the source code (MAX_SEQ), but nothing that would trigger at 5 characters. – Gilles 'SO- stop being evil' Feb 6 '13 at 15:33
  • @Profpatsch A workaround would be to make your terminal send shorter sequences. I don't know if Terminator supports this. – Gilles 'SO- stop being evil' Feb 6 '13 at 15:35
18

I found the correct answer here: Bind ctrl+up in muttrc | mail-archive.com.

Inside mutt, use the command

:exec what-key

Then pressing the desired key (like Ctrl+arrow) you can learn how to reference any key. In my case I get <C-Up> for Ctrl+Up.

Hit Ctrl-g to exit what-key.

| improve this answer | |
  • 5
    In case you succeeded in using :exec what-key to get this information, but then could not figure out "what-key" to press to get out of the what-key command, the key sequence to exit is Ctrl-g. – KDN Jan 28 '17 at 3:41
  • In any terminal/config where I tried that (with NeoMutt 20191207 or Mutt 1.13.2) what-key just give me a letter A, B, C or D. I am not the only one : mail-archive.com/mutt-users@mutt.org/msg36985.html – Bruno BEAUFILS Jun 3 at 20:54

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.