Adding and removing comments in code

You can easily add comments using either the C or C++ style, even to large sections of code. You can add two forward slash characters (//) at the beginning of lines to comment out large sections, even when they have other comment characters, such as /* */.

When you remove comments from lines, the editor removes the leading // characters from all lines that have them, so be careful not to accidentally uncomment sections. Also, the editor can comment or remove only comments from selected lines — if you highlight a partial line, the editor comments out the entire line, not just the highlighted section.

To comment or remove comments from a block of code:
  1. In the C/C++ editor, highlight a section of code to comment or remove comments. For a single line, position your cursor anywhere on that line.
  2. Right-click and select Comment or Uncomment.
Related concepts
C/C++ editor layout
Accessing source files for functions
Using code templates
Using hover help
Customizing the C/C++ editor
Using other editors
Related tasks
Finishing function names
Adding include directives