Handy Time Abbreviations in Vim

This post is part of a collection on Code and Computers.

Until recently I didn't realize how versatile abbreviations in vim were, but while looking for an easy way to insert deadlines for to-dos I found it's possible to embed arbitrary system commands with a little cleverness and came up with some useful shortcuts for timestamps.

Here they are:

iab xnow <c-r>=system("date -Is")<cr>
iab xsat <c-r>=system("date -Is -d'next saturday 10am'")<cr>
iab xsun <c-r>=system("date -Is -d'next sunday 10am'")<cr>
iab xmon <c-r>=system("date -Is -d'next monday 10am'")<cr>
iab xwed <c-r>=system("date -Is -d'next wednesday 10am'")<cr>
iab xnw <c-r>=system('date -Is -d"next week 10am"')<cr>
iab xtomorrow <c-r>=system('date -Is -d"tomorrow 10am"')<cr>

While adding input from external commands is already easy with :r!<whatever>, for frequent commands this has proved quite helpful. Ψ