Vim Tips Wiki

Manage a tasklist of to-do code snippets

1,612pages on
this wiki
Revision as of 00:20, September 30, 2008 by JohnBot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Duplicate tip

This tip is very similar to the following:

These tips need to be merged – see the merge guidelines.

Tip 1431 Printable Monobook Previous Next

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

with names:

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:


Around Wikia's network

Random Wiki