Sometimes I toggle like this between commenting and not commenting:
\documentclass{article}
\begin{document}
\catcode`^^A=14 % catcode 14 = comment
% now stuff behind ^^A is comment:
line 1
^^Aline 2
^^Aline 3
line 4
line 5
^^Aline 6
^^A\csname @firstofone\endcsname{%
^^A Line7%
^^A}%
\catcode`^^A=9 % catcode 9 = ignore
% now stuff behind ^^A is processed:
line 1
^^Aline 2
^^Aline 3
line 4
line 5
^^Aline 6
^^A\csname @firstofone\endcsname{%
^^A Line7%
^^A}%
\end{document}
^^A is TeX's ^^-notation for denoting the SOH-character which has code-point-number 1 in the TeX-engine's internal character representation-scheme, which with traditional TeX is ASCII and with LuaTeX and XeTeX is unicode.
You can use any character not in use within the code where toggling commenting/not commenting is needed. When you do so, don't forget to reset the character's category code to its usual value before resorting to using it in its usual way, e.g.,
\documentclass{article}
\begin{document}
\catcode`\X=14 % catcode 14 = comment
% now stuff behind X is comment:
line 1
Xline 2
Xline 3
line 4
line 5
Xline 6
X\csname @firstofone\endcsname{%
X Line7%
X}%
\catcode`\X=9 % catcode 9 = ignore
% now stuff behind X is processed:
line 1
Xline 2
Xline 3
line 4
line 5
Xline 6
X\csname @firstofone\endcsname{%
X Line7%
X}%
% Make sure the catcode of X is reset to its usual value
% before resorting to using X as letter.
\catcode`\X=11
\end{document}
With a hypothetical macro \tlc or with the environments provided by the package comment the stuff commented out needs to be processed for dropping it.
With the approach of toggling commenting/not commenting via toggling catcodes the stuff commented out is not tokenized/processed at all.
Therefore with the latter approach brace-balancing does not matter.
And the latter approach can also be used for commenting out snippets of code that belong to the ⟨definition text⟩ of a macro.
I.e., this does !!!not!!! work:
\documentclass{article}
\usepackage{comment}
%\includecomment{mycomment}
\excludecomment{mycomment}
\newcommand\mymacro{%
This in any case is part of the definition text.
\begin{mycomment}
This is part of the definition text only if mycomment is included.
\end{mycomment}
}%
[...]
\begin{document}
[...]
\end{document}
This does work:
\documentclass{article}
%\catcode`\^^A=9
\catcode`\^^A=14
\newcommand\mymacro{%
This in any case is part of the definition text.
^^AThis is part of the definition text only if SOH has catcode 9.
}%
[...]
\begin{document}
[...]
\end{document}
%, e.g. here). – Fran Jan 31 '21 at 17:34