Mutt uses vim as its editor, and its temp files are in /tmp/mutt-*

I want vim to auto-insert on the first line when replying to an email in mutt. here is the applicable line from my .vimrc:

autocmd BufRead /tmp/mutt-* execute 'normal gg/\n\n\n^M2j'

I don't think this line inserts (I guess I need to append 'i' to it), but that's not the problem right now. The problem is, vim called by mutt starts with the cursor on the last line, despite this addition to vimrc.

So, what am I doing wrong, and most importantly, How can I get vim to insert at the top of a reply when using mutt?

Edit: I know that it's using my .vimrc because when I intentionally enter garbage after 'execute', I get a vim error when replying.

Update: I have tried the suggestions, and the insert suggestion works great, but I have ben unable to get the insert to start at the top of the reply (i.e. the top of the tmp file vim opens).

  • JigglyNaga's suggestion helped a lot. My main problem was that in my muttrc 'editor' setting, '+' was included. Apparently this is the same as +0?
    – HorseHair
    Nov 8, 2014 at 18:28

2 Answers 2


I needed two autocmds to do this. To reach the gap between the headers and the message, search for an empty line:

autocmd BufRead /tmp/mutt-* execute "normal /^$/\n"

then to enter insert mode:

autocmd BufRead /tmp/mutt-* execute ":startinsert"
  • The insert mode works -- but getting to the top of the file is not working. Here's what I tried to get to the top of the file and insert a blank line: `autocmd BufRead /tmp/mutt-* execute "normal gg/\n" . I get this error 'Pattern not found +0'. Another user mentioned +0... I googled but I don't know what this does, or where it would come from.
    – HorseHair
    Nov 8, 2014 at 17:57
  • +n is a vim commandline option: +num: For the first file, the cursor will be positioned on line "num"
    – JigglyNaga
    Nov 8, 2014 at 18:11

If you insert 1G in there that should get you to the first line of the file.

  • Same thing as above -- stays at the last line and gives no notification of any kind
    – HorseHair
    Nov 8, 2014 at 15:38
  • @horsehair Any chance that you give it +0 on the commandline before the filename?
    – Anthon
    Nov 8, 2014 at 15:54
  • no +0 found in vimrc or muttrc
    – HorseHair
    Nov 8, 2014 at 15:59

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.