15

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. ;)

2 Answers 2

22

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.

2
  • 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
    Commented Jan 28, 2017 at 3:41
  • 1
    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/[email protected]/msg36985.html Commented Jun 3, 2020 at 20:54
6

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.

7
  • Sounds good, but it doesn’t work. \e is the escape key, not the escape character…
    – Profpatsch
    Commented Feb 6, 2013 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? Commented Feb 6, 2013 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
    Commented Feb 6, 2013 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. Commented Feb 6, 2013 at 15:33
  • @Profpatsch A workaround would be to make your terminal send shorter sequences. I don't know if Terminator supports this. Commented Feb 6, 2013 at 15:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .