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.
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.
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’.
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.
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.
In your code window, add your custom token to a specific comment and open up your Task List.
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.
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.
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.