You are here
Home > Visual Studio 2013 > Visual Studio 2013 Custom Tokens And TODO Comments

Visual Studio 2013 Custom Tokens And TODO Comments

Visual Studio 2013 Custom Tokens – This is a feature that has been around forever. It is one that I am sure is underutilized to a great extent.  So everyone probably knows about TODO comments. If you have  several things that you need to do or complete, you can add a simple To-Do list in you code by adding TODO’s.

All your TODO’s will then show up in your Task List when you set the Task List to display Comments. Custom Tokens allow you to go a step further and roll your own.

Visual Studio 2013 Custom Tokens

To create your own tokens is nice because you can now customize their meaning. For example, you might want to create TODO’s for specific sections of code or you might want to logically separate different Token Items based on the work that still needs to be done. Whatever your reason, it is rather easy to do this. Go to Tools -> Options.

visual studio 2013 custom tokens

In the search text box, type in the word ‘tokens’ and the search will filter as you type. Select the Environment -> Task List option. You will notice that there are already a few tokens in the Token List. The MSDN library has a nice explanation of the HACK, TODO and UNDONE tokens.

visual studio 2013 custom token create

In the Name text box, add the text you want for your new custom token. I just added this custom token because I couldn’t think of a suitable name, but you will probably find that the name of the custom token is largely decided by a specific need at the time. For now I just named mine ‘DirkTodo’.

visual studio 2013 custom token create high

Another nice feature is that you can specify the priority of the new custom token. Obviously this will depend on the use of the token. For this example I just specified a high priority.

visual studio 2013 custom token added

Clicking on the ‘Add’ button will enable this custom token in Visual Studio. Something I would probably have liked to have seen is the ability to add these tokens to Intellisense.

add custom token in code

In your code window, add your custom token to a specific comment and open up your Task List.

Visual Studio 2013 Custom Tokens

If you don’t see your Task List, you can enable it under the View menu or type Ctrl+W, T to enable the Task List.

Visual Studio 2013 Custom Tokens

Next, change your Task List to show Comments. Mine usually defaults to User Tasks which does not display any of the custom tokens or TODO’s.

Visual Studio 2013 Custom Tokens

You will now see that the custom token you created is listed in the Task List with a priority level of high. I simply love this feature of Visual Studio and I use it quite frequently as you can see. I do however just use TODO’s because it is quick to add in code, but sometimes a need might arise where you need to add a custom token to your code.

Then, as Zain Naboulsi pointed out, any tokens you create are not shared with other developers. This means that you will need to standardize the tokens you use and export them allowing the other developers in your company to import them.

Lastly I do have to admit that the UI isn’t the most intuitive and it seems as though it hasn’t received a lot of love from the Visual Studio team. But at the end of the day, it is functional and that i all that matters.

Dirk Strauss
Dirk is a Software Developer and Microsoft MVP from South Africa. He loves all things Technology and is slightly addicted to Twitter and Jimi Hendrix. Apart from writing code, he also enjoys writing human readable articles. "I love sharing knowledge and connecting with people from around the world. It's the diversity that makes life so beautiful." Dirk feels very strongly that pizza is simply not complete without Tabasco, that you can never have too much garlic, and that cooking the perfect steak is an art he has yet to master.
Top