]> git.cworth.org Git - notmuch-wiki/blob - vimtips.mdwn
fix intro for vimtips
[notmuch-wiki] / vimtips.mdwn
1 [[!img notmuch-logo.png alt="Notmuch logo" class="left"]]
2 # Tips and Tricks for using Notmuch with vim
3
4 Tips for using Notmuch with vim; these may be applicable when using vim with
5 [[notmuch-mutt]], [mutt-kz](https://github.com/karelzak/mutt-kz), or
6 [notmuch-vim](http://git.notmuchmail.org/git/notmuch/blob/HEAD:/vim/README).
7
8 [[!toc levels=2]]
9
10
11 ## Addressbook management and vim
12
13 There are some emacs tips over [here](http://notmuchmail.org/emacstips/#index15h2) that
14 explains how to configure emacs with an addressbook, but the few solutions were not fast enough
15 for me. And I never could test the vala-based code. So I updated the notmuch_addresses code to
16 use a cache to be able to make better matches and still be lightning fast.
17
18 And finally, [I needed](http://i.got.nothing.to/blog/2013/03/20/how-i-learned-to-stop-worrying-and-love-the-mail/) to have a way to autocomplete my recipients' addresses
19 automagically from within `vim`. So that's why I created the [notmuch_abook](https://github.com/guyzmo/notmuch-abook) code.
20 You can either install it as a plugin in vim, using vundle:
21
22         Vundle 'guyzmo/notmuch-abook'
23
24 Or if you're not using vim (which is objectively the best editor ever), you may
25 want to use it as standalone:
26
27         % pip install notmuch_abook
28
29 To configure the address book, append to `~/.notmuch-config` the following:
30
31         % cat >> ~/.notmuch-config << EOF
32
33         [addressbook]
34         path=/home/YOURUSERNAME/.notmuch-abook.db
35         backend=sqlite3
36
37         EOF
38
39 where YOURUSERNAME is your home directory. Then, you can sync the addressbook cache
40 by running. It will create the database file specified in configuration, and go through
41 all notmuch's indexed mails to get all addresses headers and cache them. It takes around
42 20 seconds on my 10000 mails index:
43
44         % notmuch_abook create
45
46 And you can query for addresses using the lookup command, which will match the beginning
47 of each word in the name and address, as follows:
48
49         % notmuch_abook lookup Foo
50         Foobar Bar <bar@bar.com>
51         Bar Foobar <bar@bar.com>
52         Bar Bar <foobar@bar.com>
53         Bar Bar <bar@foobar.com>
54         Bar Bar <bar@bar.foo>
55
56 If you're using vim, when you edit a mail having a filetype set to mail, you will be
57 able to open a completion menu when you do <C-x><C-u> at every address header.