Last year, I brought you 19 days of new (to you) productivity tools for 2019. This year, I'm taking a different approach: building an environment that will allow you to be more productive in the new year, using tools you may or may not already be using.
Doing (almost) all the things with Vim, part 1
I use two text editors regularly—Vim and Emacs. Why both? They have different use cases, and I'll talk about some of them in the next few articles in this series.
OK, so why do everything in Vim? Because if there is one application that is on every machine I have access to, it's Vim. And if you are like me, you probably already spend a lot of time in Vim. So why not use it for all the things?
Before that, though, you need to do some things. The first is to make sure you have Ruby support in Vim. You can check that with vim --version | grep ruby. If the result is not +ruby, that needs to be fixed. This can be tricky, and you should check your distribution's documentation for the right package to install. On MacOS, this is the official MacVim (not from Brew), and on most Linux distributions, this is either vim-nox or vim-gtk—NOT vim-gtk3.
I use Pathogen to autoload my plugins and bundles. If you use Vundle or another Vim package manager, you'll need to adjust the commands below to work with it.
Do your email in Vim
A good starting place for making Vim a bigger part of your productivity plan is using it to send and receive email with Notmuch using abook to access your contact list. You need to install some things for this. All the sample code below is on Ubuntu, so you'll need to adjust for that if you are using a different distribution. Do the setup with:
sudo apt install notmuch-vim ruby-mail curl -o ~/.vim/plugin/abook --create-dirs https://raw.githubusercontent.com/dcbaker/vim-abook/master/plugin/abook.vim
So far, so good. Now start Vim and execute :NotMuch. There may be some warnings due to the older version of the mail library notmuch-vim was written for, but in general, Vim will now be a full-featured Notmuch mail client.
If you want to perform a search for a specific tag, type \t, enter the name of the tag, and press Enter. This will pull up a list of all messages with that tag. The \s key combination brings up a Search: prompt that will do a full search of the Notmuch database. Navigate the message list with the arrow keys, press Enter to display the selected item, and enter \q to exit the current view.
To compose mail, use the \c keystroke. You will see a blank message. This is where the abook.vim plugin comes in. Hit Esc and enter :AbookQuery <SomeName>, where <SomeName> is a part of the name or email address you want to look for. You will get a list of entries in the abook database that match your search. Select the address you want by typing its number to add it to the email's address line. Finish typing and editing the email, press Esc to exit edit mode, and enter ,s to send.
If you want to change the default folder view when :NotMuch starts up, you can add the variable g:notmuch_folders to your .vimrc file:
let g:notmuch_folders = [ \ [ 'new', 'tag:inbox and tag:unread' ], \ [ 'inbox', 'tag:inbox' ], \ [ 'unread', 'tag:unread' ], \ [ 'News', 'tag:@sanenews' ], \ [ 'Later', 'tag:@sanelater' ], \ [ 'Patreon', 'tag:@patreon' ], \ [ 'LivestockConservancy', 'tag:livestock-conservancy' ], \ ]
There are many more settings covered in the Notmuch plugin's documentation, including setting up keys for tags and using alternate mail programs.
Consult your calendar in Vim
Sadly, there do not appear to be any calendar programs for Vim that use the vCalendar or iCalendar formats. There is Calendar.vim, which is very well done. Set up Vim to access your calendar with:
cd ~/.vim/bundle git clone email@example.com:itchyny/calendar.vim.git
Now, you can see your calendar in Vim by entering :Calendar. You can switch between year, month, week, day, and clock views with the < and > keys. If you want to start with a particular view, use the -view= flag to tell it which one you wish to see. You can also add a date to any of the views. For example, if I want to see what is going on the week of July 4, 2020, I would enter :Calendar -view week 7 4 2020. The help is pretty good and can be accessed with the ? key.
Calendar.vim also supports Google Calendar (which I need), but in December 2019 Google disabled the access for it. The author has posted a workaround in the issue on
So there you have it, your mail, addresses, and calendars in Vim. But you aren't done yet; you'll do even more with Vim tomorrow!