Handy Time Abbreviations in Vim

2016-02-03T00:49:18+0900

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. Ψ