Manage a tasklist of to-do code snippets
From Vim Tips Wiki
created November 30, 2006 · complexity basic · author David J Hamilton · version n/a
This tip is inspired by the Eclipse task list feature, which automagically populates tasks when you put comments in Java code with a prefix of "TODO".
The idea is to create a tag for each TODO entry and then create a Vim command to list only those tags. The example will be for Java, but you'll see that it should work for any language.
Assuming you use ctags to generate your tags file, add the following to ~/.ctags:
This will cause ctags to create tags for the following code:
//TODO djh fix this horrible hack //TODO djh comment this
todo djh fix this horrible hack todo djh comment this
You can then add the following to vimrc to create a command that easily lists these.
command TODO tselect /^todo djh
Note that I'm only interested in TODOs that begin with my initials - you may want to simply use /^todo. Be careful though! If you have case-insensitivity turned on, you may get false positives for tags of the form 'toDouble'. This can be fixed by changing your todos to //TODO: