Comment out multiple lines in LaTeX.
Highlight the lines and press Ctrl + / on Windows or Cmd + / on Mac to comment them instantly. For larger blocks, use the comment package or the verbatims environment instead of typing percentage signs on every single line.
The short answer: use the keyboard shortcut Ctrl + / or Cmd + / for selected lines, or wrap a whole paragraph in \begin{comment} and \end{comment} using the comment package for larger blocks.
The keyboard shortcut
The fastest way to comment out several lines in an online editor like Overleaf or Texeno is with a keyboard shortcut. Select the lines you want to hide, then press Ctrl + / on Windows or Linux, or Cmd + / on Mac.
The editor adds a percentage sign to the start of each highlighted line. Press the same keys again to uncomment them. If your keyboard layout lacks a forward slash key in its default position, try Ctrl + Shift + 7 on Windows or Cmd + Shift + 7 on Mac as an alternative.
The comment package for large blocks
When you need to hide entire pages of draft text, experimental sections, or notes, typing percentage signs on every line becomes tedious. The comment package provides an environment that ignores everything inside it without needing individual percentage symbols.
Put \usepackage{comment} in your preamble, then wrap any block of text in comment environments.
Code examples for different needs
Using the comment package
Add the package to your preamble and wrap the ignored text in comment environments. Nothing inside the environment appears in the compiled PDF.
\usepackage{comment} \begin{document} This text compiles. \begin{comment} All of this text is ignored by LaTeX. You can write multi-line notes, old drafts, or broken paragraphs here without deleting them. \end{comment} This text compiles again. \end{document}Using verbatim for code snippets
If you need to show raw LaTeX code or symbols that would otherwise break the compiler, use the verbatim environment instead.
\begin{verbatim} % This is not a comment. % It prints literally in the PDF: \section{Uncompiled code} This text is shown as typewriter font. \end{verbatim}
Common issues with multi-line comments
Nested comments fail
The standard comment package does not support nested comment blocks. If you place \begin{comment} inside another comment environment, LaTeX gets confused and throws errors about missing ends.
Formatting inside comments
Text inside comment environments is completely ignored, but it must still use valid characters. Unescaped special characters like raw ampersands or stray backslashes rarely cause issues since the parser ignores them, but mismatched braces can sometimes upset syntax highlighters.
Questions
What is the keyboard shortcut to comment out lines in Overleaf?
Press Ctrl + / on Windows and Linux, or Cmd + / on Mac, after selecting the lines you want to comment out.
How do I comment out a whole chapter without percentage signs?
Add \usepackage{comment} to your preamble and wrap the text in \begin{comment} and \end{comment} environments.
Does the comment package work in Texeno?
Yes. Texeno supports all standard LaTeX packages, including comment, verbatim, and listings.
Try your own paper in Texeno.
Start free, upload a project as a .zip and press Recompile. Upgrade when you need longer compiles.
Start writing