This plug-in lets you complete e-mail addresses in Vim by those found in your inbox (or any other mail folder) via notmuch.
Useful, for example, when using Vim
as editor for mutt
(especially with $edit_headers
set).
The more recent plugin mutt-query-complete.vim lets you complete e-mail addresses in Vim by the more general $query_command
set up in Mutt.
It encompasses this plug-in by setting in your muttrc
set query_command="notmuch-addrlookup --format=mutt '%s'"
and is therefore obsoleted.
When you're editing a mail file in Vim that reads
From: Fulano <Fulano@Silva.com>
To: foo
and 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
.
-
Copy the folders of this repository into your Vim runtime path (
~/.vim
on Linux and macOS), and -
download and install (by
make && sudo cp notmuch-addrlookup /usr/local/bin
) notmuch-addrlookup. If you are missing superuser rights, then compile it (bymake
) and add the path of the folder that contains the obtained executablenotmuch-addrlookup
(say~/bin
) to your environment variable$PATH
: If you usebash
orzsh
, by adding to~/.profile
or~/.zshenv
the linePATH=$PATH:~/bin
If the executable
notmuch-addrlookup
is unavailable, butnotmuch
is, thennotmuch address
will be used instead; whose results are however less pertinent.
If you use vim-plug, then both steps can be achieved at once by pasting the following code snippet into your vimrc
(between call plug#begin()
and call plug#end()
):
Plug 'Konfekt/vim-notmuch-addrlookup'
if !executable('notmuch-addrlookup')
Plug 'aperezdc/notmuch-addrlookup-c', { 'do': 'make' }
let $PATH .= expand(':~/.vim/plugged/notmuch-addrlookup-c')
endif
-
Completion is enabled in all mail buffers by default. Add additional file types to the list
g:notmuch_filetypes
which defaults to[ 'mail' ]
. To enable completion in other buffers, run:NotmuchCompletion
. -
If you 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:notmuch_filter = 1
to your
vimrc
, which will discard all e-mail addresses that satisfy the regular expression given by the variableg:notmuch_filter_regex
that defaults tolet g:notmuch_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 plug-ins vim-notmuch-address and vim-notmuch-addresses achieve the same, but use
notmuch address
exclusively. - The plugin mutt-query-complete.vim lets you complete e-mail addresses in Vim by the
$query_command
set up in Mutt - 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 Adrian Perez's notmuch-addrlookup.
- 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
.