[neomutt-users] automatically insert text in messages

Kian Kasad kian at kasad.com
Tue Feb 16 18:06:34 CET 2021


On 21/02/16 12:08PM, Sam Kuper wrote:
> On Tue, Jan 07, 2020 at 08:04:21PM -0800, Steve Quezadas wrote:
> > do any of you guys use vim with neomutt? I do customer support
> > sometimes and it's useful to sometimes insert standard letters to
> > common questions.
> > 
> > Are there any tools to automatically do this? I realize this more of a
> > vim question, but I figure more people would encounter this problem
> > with mutt.
> 
> Vim is easily capable of this.

What isn't it capable of? :)

> Suppose you want to be able to (while in Vim in normal mode) hit your
> leader key followed by "aa", to insert "Thank you for using Acme Corp!"
> Stick this in your vimrc:
> 
>     :nnoremap <Leader>aa Thank you for using Acme Corp!<esc>

You'd have to enter insert mode first, since this is an 'nmap', not
'imap':

	:nnoremap <Leader>aa aThank you for using Acme Corp!<esc>

I'd actually recommend using vim's built-in abbreviation functionality
for this, as it's designed for doing exactly this. That being said, it
expands text in insert mode, or when using commands (like :s) to edit
lines. It won't work if you want a normal-mode mapping that inserts the
text. For more info, do:

	:h abbreviations

An example to create an abbreviation, which expands "aa" to the same
text as the example above:

	:abbrev aa Thank you for using Acme Corp!

Then whenever you type aa (*in Insert mode*) as its own word, it will be
expanded. But it would not expand, for example, "aardvark", "aaaaah", or
"haaaa", since these are not standalone occurrences of "aa".

I'm sure there are also plenty of (in my opinion) over-engineered
plugins to do exactly this, too.

--
Kian Kasad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <https://mailman.neomutt.org/pipermail/neomutt-users-neomutt.org/attachments/20210216/75b96086/attachment.sig>


More information about the neomutt-users mailing list