Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

mutt/vim compose-new-mail macro

0 views
Skip to first unread message

Gary Johnson

unread,
Aug 26, 2002, 12:50:45 PM8/26/02
to
On Mon, Aug 26, 2002 at 06:53:37AM -0400, Russell Hoover wrote:
> When I am in mutt and I press 'm' to compose a new mail, and I'm then
> dropped into my editor (vim), I'd like to have it so that I'll always
> be automatically already in vim's insert mode.
>
> Right now, once mutt puts me into vim after I press 'm',
> and I am in vim's 'normal mode' ready to compose a new mail,
> I can invoke vim's 'O' command (open a new line above the
> cursor and put the editor into insert mode) to get exactly
> what I want -- insert mode plus the new line.
>
> What I'd like to do is put the 'O' command into a mutt macro,
> and I've forgotten how I'd do it.
>
> I already have this:
>
> # Start cursor at line 9 (with edit_hdrs set) when composing new mails ('m'):
> macro index m ":set editor='vim +9'^M_A" "compose a new mail message"
> macro pager m ":set editor='vim +9'^M_A" "compose a new mail message"
>
> (Earlier in my .muttrc I bound "_A' to (send a) mail, ('m' by default), so
> that 'm' could be the key for the macro.)
>
> How do I put vim's 'O' command into a this macro so that it does what
> I want?

From the shell prompt, you could do this:

vim +9 -c "normal O" -c startinsert

You may want to search for a pattern rather than use a line number in
case the number of header lines ever changes:

vim +/^$ -c "normal O" -c startinsert

Now the tricky part is quoting this correctly for use in a macro. This
worked when I tried it, without the ^M_A:

macro index m ":set editor='vim +9 -c \"normal O\" -c startinsert'^M_A" "compose a new mail message"

HTH,
Gary

--
Gary Johnson | Agilent Technologies
gary...@spk.agilent.com | Spokane, Washington, USA
http://www.spocom.com/users/gjohnson/mutt/ |

Rob 'Feztaa' Park

unread,
Aug 26, 2002, 1:03:57 PM8/26/02
to

--EeQfGwPcQSOJBaQU
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Alas! Russell Hoover spake thus:


> How do I put vim's 'O' command into a this macro so that it does what
> I want?

Just set your editor to be '/usr/bin/vi "+O"' and it will automatically
do whatever the O key does when vim launches.

--=20
Rob 'Feztaa' Park
http://members.shaw.ca/feztaa/
--
Your password is pitifully obvious.

--EeQfGwPcQSOJBaQU
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9amD4PTh2iSBKeccRAq6NAJ94X63v9lPSjJJFAkQEHTELd7CumwCdF8gK
Q1ZPi0bYDGwR41dV7fFxYRs=
=CCwn
-----END PGP SIGNATURE-----

--EeQfGwPcQSOJBaQU--

0 new messages