Friday, March 7, 2008

Vimming your way to the top

Here's the Vim syntax file I use for highlighting my to-do list. It's based on the syntax file for YAML.
http://www.vim.org/scripts/script.php?script_id=2599

Benefits:
  • Different colors for lines ending in ':', or starting with '*' or '{'
  • Assign keywords to be automatically highlighted, like important locations, coworkers' names, customers, taquerias, etc.
  • Start sections with a line of underscores and a heading beginning with the '{' character. The heading stands out (red with GVim's "desert" color scheme), and you can jump between sections just like C blocks using ]] and [[ keystrokes.
  • Ordinary text (i.e. not specifically formatted for this syntax) looks sane.
Normally I have a line in my .vimrc assigning the filetype "todolist" to the file where I keep my permanent todolist, but another way to add this highlighting to a text file is to add vim: ft=todolist to the end of a file. It's harmless.

Update (4/2/09): I uploaded the script to vim.org, where it will be easier to track and update.

Update (1/1/10): Here's an example of how to use this color scheme for course notes.


  • 60 underscores (my preference) and a curly brace indicate a new section
  • Subsection lines end with a colon (generally followed by bullet points)
  • Special or out-of-context notes start with an asterisk
  • For separation, or to display a different sort of sub-heading, play with asterisks: '* * *' centered, or '** OLD **' for example
At school, I run a shell script for each new class that creates a new directory from the course name, copies a skeleton of this example text to a file called lecture-notes.txt, etc., and adds the directory to Mercurial -- so while there's some boilerplate involved with this plugin, it's easy to automate and plays well with Vim's text-munging capabilities.

I've also picked up the habit of putting @contexts above unsorted items at the top of my main to-do list, inspired by the GTD approach. The syntax plugin doesn't take advantage of this yet; I'll post another update when that's done.