By default, when entering information at the command prompt in mutt, you can clear the prompt with Ctrlg, as described in the manual:

^G              n/a             abort

I have been trying to bind this function to Escape. Unfortunately, abort is not listed in the available functions, either in the manual, or in the source.

I have tried using this in my .muttrc:

bind editor <esc>       abort

but it throws an error:

Error in /home/jason/.mutt/muttrc, line 143: abort: no such function in map

I have tried using a different map, like (generic) and experimented with other fictitious functions, like clear, to no avail.

How would I bind Escape to clear the prompt line?

  • 1
    Binding escape is not a good idea as the escape character (sent upon pressing escape) is also the prefix for escape sequences sent by all function keys like arrows, del, F1... Sep 11, 2012 at 6:20
  • That's a good point that I had not considered. Testing it, Escape needs to be sent twice to send a literal ^[ so it may not be a showstopper (I don't use any binds that rely on it anyway).
    – jasonwryan
    Sep 11, 2012 at 6:58
  • Esc, Esc would send two ESC characters. You can also press Esc once and wait about one second (the default timeout waiting for the rest of an escape sequence). Sep 11, 2012 at 9:19
  • Yes. First I have to work out how to bind it :)
    – jasonwryan
    Sep 11, 2012 at 9:20

4 Answers 4



It's not possible with key bindings. Ctrl-G is hardcoded in mutt at a lower level than the macro or keybinding processing (see mutt_getch() in mutt's source code, at the core of all user input in mutt that returns an error upon ^G).

macro editor \e '^G'

wouldn't work either.

What you can do is configure your terminal to send ^G upon pressing Escape

With xterm:

xterm -xrm 'XTerm.VT100.translations: #override <KeyPress> Escape: string(0x7)'

If you're using screen, you can also do

screen -X bindkey $'\e' stuff $'\a'

before calling mutt and restore it afterwards (unfortunately, it doesn't seem you can have per screen window key bindings in screen). Also, it's going to be a problem if your editor for email messages is vi.


Since release 20200313 There's $abort_key config variable to change the default Ctrl-G.

  • Upvoted: because it answers the question (ie., it's not possible). Could you please elaborate on the "hardcoded... at a lower level". And while the workaround is ingenious, it is not really practicable as I use Escape in a lot of other terminal programs--hence the desire to bind it here.
    – jasonwryan
    Sep 11, 2012 at 9:41
  • I've edited my answer with more details. I'm surprised you have Esc bound in other programs as it usually isn't in applications I know for the reason mentioned in comments above. Sep 11, 2012 at 11:22

It seems like a really bad idea to me to bind escape to ControlG also. I came here looking for a mutt solution, but since it seems there is none, I'll give an answer from what I'm doing for anyone who happens to stumble across this. It's not optimal but it won't affect any other programs:

macro editor \e "<enter><shell-escape>xdotool key control+g<enter>"


macro editor \e "<enter><shell-escape>xsendkey Control+g<enter>"

Using something like xdotool or xsendkey to fake control+g works and doesn't mess up escape everywhere else. There's a visual delay for me for it to exit the line editor, but index bindings will work immediately and the visual delay will be gone as soon as you use an index binding. The first enter is necessary so that mutt won't just type out "...." and make that into a header or search term or something.


For NeoMutt, since Release 2020-03-13, you can do this:

set abort_key = "<Esc>"

Also you'd better also put this line in your startupscript like .bashrc:

export ESCDELAY=0

The reason, quoted from here, is

Please note that when using as the abort key, you may also want to set the environment variable ESCDELAY to a low value or even 0 which will reduce the time that ncurses waits to distinguish singular key presses from the start of a terminal escape sequence. The default time is 1000 milliseconds and thus quite noticeable.

Credit to @Stéphane Chazelas for pointing out the abort_key option. I think it serves viewers better to make this a separate detailed answer.


This solution is so bad that the author prefered to edit Mutt's source code to get rid of ^G

Warning: This solution seems incompatiple with OSX, Emacs and other aplications that use Ctrl+G

After my first day at Mutt, I was almost using ^G in Vim by mistake... Then I tried something that seems to work here, in i3 window manager and xfce-terminal.

Added this line to ~/.i3/config:

bindsym --release Escape exec --no-startup-id xvkbd -xsendevent -text "\[Escape]\[Control]\[g]"

Had to use "\[Escape]\[Control]\[g]" because only "\[Control]\[g]" made it stop working in Vim.

If you are not using i3, I think you can use xbindkeys to run xvkbd -xsendevent -text "\[Escape]\[Control]\[g]" when Esc is pressed.

It's not a beautiful solution... It can make your Esc key unusable in some programs, but at least here it seems ok.


I see now that the Ctrl+G part makes Vim shows position in file. Nothing too dramatic, for now.

This link seems to have a better solution, but for urxvt: http://www.unixli.com/q/answers-urxvt-map-esc-key-to-key-sequence-83211.html

You must log in to answer this question.

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