Toggle Line Comment
What is Toggle Line Comment?
Toggle Line Comment: Comment or uncomment the current line (or selection). Works in any language. Toggle Line Comment comments out the current line or selected lines, or uncomments them if they already are. In VS Code and JetBrains IDEs it is Ctrl+/ or Cmd+/. The editor uses the right comment style for the language: // in PHP and JavaScript, # in Python and YAML, <!-- --> in HTML. Block comments have their own shortcut, Shift+Alt+A in VS Code.
Frequently asked questions about Toggle Line Comment
What should you keep in mind with Toggle Line Comment?
It is handy for temporarily disabling code while debugging. Do not leave large blocks of commented-out code in the codebase, though. Version control already remembers old code, and commented blocks confuse later readers, who cannot tell whether the code is still needed. Delete it, and fetch it from Git history if you ever need it again.
At a glance
| Category | Keyboard shortcuts |
|---|---|
| Explained by | Reinier de la Parra |
| Updated |