Fandom

Vim Tips Wiki

Manage a tasklist of to-do code snippets

1,624pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

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:

--regex-java=/\/\/TODO(.*)/todo\1/

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:

CommentsEdit

Also on Fandom

Random Wiki