/vim-mutt-aliases

Vim plug-in to complete aliases of the mail client mutt in Vim

Primary LanguageVim Script

Complete mutt aliases (listed in ~/.mutt/aliases) inside Vim; useful

  • when using Vim as editor for mutt (especially with $edit_headers set), and
  • even more so with the shell script mutt-alias.sh to populate the aliases file with recent e-mail addresses in your Inbox (or Sent folder).

Usage

When you're editing a mail file in Vim that reads

    From: Lu Guanqun <guanqun.lu@gmail.com>
    To:   foo

and in your mutt aliases file there is an entry

    alias foo foo@bar.com

and your cursor is right after foo, then hit Ctrl+X Ctrl+U to obtain:

    From: Lu Guanqun <guanqun.lu@gmail.com>
    To:   foo@bar.com

Commands

The command :EditAliases opens the mutt aliases file in Vim. (For less typing, you can (command-line) alias it to ea by vim-alias)

To complete e-mail addresses press CTRL-X CTRL-U in insert mode. See :help i_CTRL-X_CTRL-U and :help compl-function.

Setup

Completion is enabled in all mail buffers by default. Add additional file types to the list g:muttaliases_filetypes which defaults to [ 'mail' ]. To enable completion in other buffers, run :MuttAliasesCompletion.

The mutt aliases file is automatically set to the value of the variable $alias_file used by mutt. To explicitly set the path to a mutt aliases file $file, add to your .vimrc the line

  let g:muttaliases_file = '$file'

For example, $file could be

  ~/.mutt/aliases

As a suggestion, if you use different mail accounts with different aliases, add in .muttrc a folder hook, say for the account mailo,

folder-hook '~/.local/share/mbsync/mailo/' 'source "$XDG_CONFIG_HOME/mutt/accounts/mailo"'

and in "$XDG_CONFIG_HOME/mutt/accounts/mailo" tell Vim about the alias file by

set editor = 'vim +"let g:muttaliases_file=\"$XDG_CONFIG_HOME/mutt/accounts/mailo.aliases\"" %s'

Related:

  • To add aliases

  • The plugin mutt-query-complete.vim lets you complete e-mail addresses in Vim by the $query_command set up in Mutt

Credits

Forked from Lu Guanqun's vim-mutt-aliases-plugin.

License

Distributable under the same terms as Vim itself. See :help license.