TODO comments
Sometimes, you need to mark parts of your code for future reference: areas of optimization and improvement, possible changes, questions to be discussed, and so on. CLion lets you add special types of comments that are highlighted in the editor, indexed, and listed in the TODO tool window. This way you and your teammates can keep track of issues that require attention.
By default, there are two patterns recognized by CLion: TODO
and FIXME
in both lower and upper case. These patterns can be used inside line and block comments of any supported file type. You can modify the default patterns or add your own patterns if necessary.
Create a multiline TODO item
Indent the text in comment lines that follow the initial comment line.
You can use spaces and tabs, or a mix of both for indenting multiline TODO items.
Disable multiline TODO items
Press Ctrl+Alt+S to open the IDE settings and then select
.Clear the Treat indented text on the following lines as part of the same TODO checkbox.
You can view all the available TODO items in the TODO tool window ( ). To jump to the location of the relevant comment in the source code, double-click the corresponding TODO item in the TODO tool window. To automatically jump to the location of the relevant comment every time you select the corresponding TODO item, right-click the TODO tool window title bar, point to View Options, and select Navigate with Single Click (this option is enabled by default).
Add custom patterns and filter TODO items
You can add your own patterns and filter the list to show only TODO items that match certain patterns. For example, you can choose to mark places of possible optimization in your code with the OPTIMIZE
pattern and ignore all other types of TODO items when viewing them in the TODO tool window.
In the Settings dialog (Ctrl+Alt+S) , select .
Use a regular expression to specify a custom pattern.
For example, to add a pattern for the word
OPTIMIZE
in a comment, click in the Patterns section of the TODO dialog, and type the following regular expression:\boptimize\b.*This matches the word "optimize" (
\b
designates word boundaries) and allows any number of other characters in the comment.Then click OK to save the new pattern.
Add a filter to group TODO patterns and view the corresponding TODO items in the TODO tool window separately.
For example, to add the
Optimization
filter with the new pattern, click in the Filters section of the TODO dialog, specifyOptimization
as its name and select the new pattern to be included in this filter.Then click OK to save the new filter.
Click OK to apply the changes in the TODO settings dialog.
To apply the new filter, in the TODO tool window, click and select the
Optimization
filter.
The icon that you select for a pattern is displayed in the TODO tool window to better distinguish various TODO items. By enabling the Case Sensitive checkbox for a pattern, you can force the pattern to match only with the specified case.