This plug-in lets you complete e-mail addresses in Vim by those found in your inbox (or any other mail folder) via mail-query.
Useful, for example, when using Vim
as editor for mutt
(especially with $edit_headers
set).
When you're editing a mail file in Vim that reads
From: Fulano <[email protected]>
To: foo
and in your Inbox there is an e-mail from
Mister Foo <[email protected]>
and your cursor is right after foo
, then hit Ctrl+X Ctrl+O
to obtain:
From: Fulano <[email protected]>
To: Mister Foo <[email protected]>
To complete an e-mail address inside Vim press CTRL-X CTRL-O
in insert
mode. See :help i_CTRL-X_CTRL-O
and :help compl-omni
.
-
Download and install (by
sudo make install
) mail-query. If you are missing superuser rights, then compile it (bymake
) add the path of the folder that contains the obtained executablemail-query
(say~/bin
) to your environment variable$PATH
: If you usebash
orzsh
, by adding to~/.profile
or~/.zshenv
the linePATH=$PATH:~/bin
To decode 7-bit ASCII encoded MIME-headers (which start, for example, with
=?UTF-8?Q?
or=?ISO-8859-1?Q?
), ensure thatperl
is executable and the Encode::MIME:Header module is installed. Please note that when completing non-ASCII
characters, then onlyUTF-8
encoded non-ASCII
characters in the mail folder can be found, but none encoded inISO-8859-1(5)
or any other encoding (common before the advent ofUTF-8
in the nineties). -
Completion is enabled in all mail buffers by default. Add additional file types to the list
g:mailquery_filetypes
which defaults to[ 'mail' ]
. To enable completion in other buffers, run:MailqueryCompletion
. -
The mail folder is automatically set to the value of the variable
$folder
used bymutt
. To explicitly set the path to a mail folder$folder
, add to your.vimrc
the linelet g:mailquery_folder = '$folder'
For example, if you use
mbsync
, then$folder
could be$XDG_DATA_HOME/mbsync/INBOX/cur
-
If you would like to filter out most probably impersonal e-mail addresses such as those that come from mailer daemons or accept no reply, then try adding
let g:mailquery_filter = 1
to your
vimrc
, which will discard all e-mail addresses that satisfy the regular expression given by the variableg:mailquery_filter_regex
that defaults tolet g:mailquery_filter_regex = '\v^[[:alnum:]._%+-]*%([0-9]{9,}|([0-9]+[a-z]+){3,}|\+|nicht-?antworten|ne-?pas-?repondre|not?([-_.])?reply|<(un)?subscribe>|<mailer\-daemon>)[[:alnum:]._%+-]*\@'
- The plugin vim-notmuch-addrlookup lets you complete e-mail addresses in Vim by those indexed by notmuch.
- The vim-mutt-aliases plug-in lets you complete e-mail addresses in Vim by those in your
mutt
alias file and (when the alias file is periodically populated by the mutt-alias.sh shell script) gives a more static alternative to this plug-in.
- to Patrick Brisbin's mail-query.
- to Lu Guanqun as the fork vim-mutt-aliases of Lu Guanqun's vim-mutt-aliases-plugin served as a template.
Distributable under the same terms as Vim itself. See :help license
.