I cannot find a way to comment and uncomment multiple lines of code in Visual Studio Code.
Is it possible to comment and uncomment multiple lines in Visual Studio Code using some shortcut? If yes, how to do it?
To comment out multiple code lines right-click and select Source > Add Block Comment. ( CTRL+SHIFT+/ ) To uncomment multiple code lines right-click and select Source > Remove Block Comment. ( CTRL+SHIFT+\ )
To comment out an entire block of code: Select the code and select Toggle Line Comment(s) from the context menu.
Windows: Ctrl + K + U. Mac: Command + K + U.
Shift+Alt+A
Here you can find all the keyboard shortcuts.
All VSCode Shortcuts
PS: I prefer Ctrl+Shift+/ for toggling block comments because Ctrl+/ is shortcut for toggling line comments so it's naturally easier to remember. To do so, just click on the settings icon in the bottom left of the screen and click 'Keyboard Shortcuts' and find "toggle block...". Then click and enter your desired combination.
First, select the lines you want to comment/uncomment (CTRL+L is convenient to select a few lines)
Then:
To toggle line comments, execute editor.action.commentLine
(CTRL+/ on Windows)
or
To add line comments, execute editor.action.addCommentLine
(CTRL+K CTRL+C)
To remove line comments, execute editor.action.removeCommentLine
(CTRL+K CTRL+U)
or
To toggle a block comment, execute editor.action.blockComment
(SHIFT-ALT-A)
See the official doc : Key Bindings for Visual Studio Code
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With