I'd like to use
ftplugin/mail.vim to execute a normal command after opening an email in Mutt.
Specifically, when replying to an email, I'd like move the cursor after the header fields (I have
set edit_headers in my muttrc) and before the text of the email I reply to:
From: Me <firstname.lastname@example.org> To: Recipient <email@example.com> Cc: Bcc: Subject: Re: The mail subject Reply-To: In-Reply-To: <id@example> On 2021-01-01 at 09:13:16, Recipient (firstname.lastname@example.org) wrote: > The email > I'm > replying to
In other words, I want to jump to the empty line after
I know that the normal command
} should suffice to jump over the paragraph of headers, thus I added this to
Unfortunately, that takes me to the bottom of the buffer, not to the empty line.
This works though:
ftplugin/mail.vim. I could go with that, but it seems to me that
normal }doesn't belong in
- Adding this to my muttrc:
set editor="vim -c 'normal }'". Like above, I feel it would be cleaner to add that command to
ftplugin/mail.vimthe right place for
- If so, how can I jump to the first empty line in an email?
I'm using Neovim v0.4.4 on Arch Linux 5.9.14.
I encountered some strange behavior while testing
normal commands: When adding
normal iABCDE to
ftplugin/mail.vim I see "ABCDABCDEE" is written to the file. As if
ftplugin/mail.vim was executed twice.
Cause of the issue
I figured out the issue thanks to filbranden's answer.
ftplugin/mail.vim was indeed sourced twice due to this in my
init.vim (Neovim's equivalent to vimrc):
let vimDir = '$XDG_CONFIG_HOME/nvim' let &runtimepath.= ',' . vimDir
The problem was the second line that appended my config directory, effectively making
~/.config/nvim appear at the beginning and the end of the runtime path.
normal } in
ftplugin/mail.vim works now, I still put my mail config in
after/ftplugin/mail.vim since I want to override the textwidth config in
/usr/share/nvim/runtime/ftplugin/mail.vim. The contents of
after/ftplugin/mail.vim are now:
setlocal textwidth=0 " Thanks for the tip, B Layer normal! }