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 <Fulano@Silva.com>
To: fooand in your Inbox there is an e-mail from
Mister Foo <foo@bar.com>and your cursor is right after foo, then hit Ctrl+X Ctrl+O to obtain:
From: Fulano <Fulano@Silva.com>
To: Mister Foo <foo@bar.com>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 usebashorzsh, by adding to~/.profileor~/.zshenvthe 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 thatperlis executable and the Encode::MIME:Header module is installed. Please note that when completing non-ASCIIcharacters, then onlyUTF-8encoded non-ASCIIcharacters in the mail folder can be found, but none encoded inISO-8859-1(5)or any other encoding (common before the advent ofUTF-8in the nineties). -
Completion is enabled in all mail buffers by default. Add additional file types to the list
g:mailquery_filetypeswhich defaults to[ 'mail' ]. To enable completion in other buffers, run:MailqueryCompletion. -
The mail folder is automatically set to the value of the variable
$folderused bymutt. To explicitly set the path to a mail folder$folder, add to your.vimrcthe linelet g:mailquery_folder = '$folder'
For example, if you use
mbsync, then$foldercould 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_regexthat 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
muttalias 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.