Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: d1829f923a76118424de56681e33447ad18029aa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Commenting out code</title>
<link rel="stylesheet" type="text/css" href="../help.css">
</head>

<body>

<div role="main"><h1>Commenting out code</h1>

<p>You can comment out one or more lines of code in any C/C++ editor view. 
The leading characters <samp>//</samp> are added to the beginning of each line when commenting one or more lines of code.
You can also block comment multiple lines of code using the characters <samp>/* */</samp>.</p>

<p><strong>Tip:</strong> The characters <samp>/* */</samp> on lines that already are 
already commented out are not affected when you comment and uncomment code as 
described above.</p>

<p><img src="../images/cdt_menu_toggle_comments.png" alt="Commenting out code menu choices"></p>

<p>To toggle <samp>//</samp> comments on code:</p>

<ol>
  <li>In the C/C++ editor, select the line(s) of code that you want to comment out.  If no lines are selected comments will be added (or removed) at the current cursor position.</li>
  <li>Right-click and select <strong>Source &gt; Toggle Comment</strong>. (<samp>CTRL+/</samp>)</li>
  </ul>
</ol>

<p>To block comment <samp>/* */</samp> code:</p>

<ol>
  <li>In the C/C++ editor, select multiple line(s) of code to comment out.</li>
  <li>To comment out multiple code lines right-click and select <strong>Source &gt; Add Block Comment</strong>. (<samp>CTRL+SHIFT+/</samp>)</li>
  <li>To uncomment multiple code lines right-click and select <strong>Source &gt; Remove Block Comment</strong>. (<samp>CTRL+SHIFT+\</samp>)</li>
  </ul>
</ol>

 <p><img src="../images/ngconcepts.gif" ALT="Related concepts" width="143" height="21">
<br>
 <a href="../concepts/cdt_o_code_entry.htm">Code entry</a></p>
<p><img src="../images/ngtasks.gif" ALT="Related tasks" width="143" height="21">
<br>
<a href="cdt_t_cust_cpp_editor.htm">Customizing the C/C++ editor</a><br>
<a href="cdt_o_con_assist.htm">Working with Content Assist</a></p>
<p><img src="../images/ngref.gif" ALT="Related reference" width="143" height="21">
<br>
<a href="../reference/cdt_o_ceditor_pref.htm">C/C++ editor preferences</a></p>
<hr >
<img src="../images/ng00_04a.gif" ALT="IBM Copyright Statement" >

</div></body>

</html>

Back to the top