How to comment multiple lines in Visual Studio code?

I cannot find a way to comment / uncomment several lines of code in VS Code .

Is it possible to comment / uncomment several lines in VS code in some shortcut?

How to do it?

Thank.

+86
visual-studio-code
Dec 16 '15 at 15:40
source share
17 answers
  • Select the lines you want to comment / uncomment
  • Run the editor.action.commentLine command (default shortcut on Windows: CTRL + / )

    or

    run the editor.action.addCommentLine command (default shortcut on Windows: ctrl+k ctrl+c ) respectively editor.action.removeCommentLine (default shortcut on Windows: ctrl+k ctrl+u )

See white paper: Key Bindings for Visual Studio Code

+97
Dec 16 '15 at 16:21
source share

The keyboard shortcut for comments on Windows is "Shift + Alt + A."

+57
Jul 28 '16 at 6:57
source share

You can see all the available keywords in the official documentation .

Here is the corresponding bit for osx:

 Key Command ⌘K ⌘C Add Line Comment ⌘K ⌘U Remove Line Comment ⌘/ Toggle Line Comment ⇧βŒ₯A Toggle Block Comment 

You will need to first select the lines you want to comment on, and then execute the above shortcut, i.e. ⌘/ in osx Ctrl/ in Windows.

+20
Dec 16 '15 at 16:24
source share

In my case (ubuntu) this is

Ctrl + Shift + A

+17
Feb 20 '17 at 10:57
source share

For my keyboard layout, Ctrl + Β§ for:

 // // // 

And Shift + Alt + A for:

 /* ... */ 
+9
Apr 04 '17 at 8:06 on
source share
  • Select the entire line you want to comment

  • CTRL + /

+3
Mar 30 '17 at 19:22
source share

On MacOS comment out a few lines in Visual Studio code using a keyboard shortcut:

Option + Shift + A

 /* ... ... */ 
+3
Dec 06 '17 at 6:53 on
source share

For me it was ctrl + ' (I use the Swedish layout for the keyboard). Hope someone helps.

+2
Aug 28 '17 at 19:49 on
source share

CTRL + SHIFT + A for multi-line CSS

  • Ubuntu 16
  • VSIode Version 1.17.2
+2
Nov 03 '17 at 14:45
source share

CTRL + / comment / uncomment several lines of code

ctrl + k + u for the uppercase last

ctrl + k + l for lowercase

+1
Jul 19 '17 at 6:26
source share

1.Select the text, press Cntl + K, C to comment (Ctr + E + C) 2. Move the cursor to the first line after the // separator and before the code text. 3. Press Alt + Shift and use the arrow keys to select .... 4. To make a selection, press the spacebar to enter one space.

+1
Oct. 31 '17 at 20:08
source share

CTRL + SHIFT + A For Red Hat, centos

  • Select item
  • then CTRL + SHIFT + A
+1
Dec 12 '17 at 5:48
source share

You can view existing shortcuts using the same steps as below. I find this to be inconvenient by default, so I used the following process to change the IDE to use the '/' command seen in the comments.

You can customize keyboard shortcuts by going to the "Tools" menu and selecting "Options." Then select "Keyboard" in the "Environment" branch. From there, you can bind the Edit.CommentSelection and Edit.UncommentSelection commands to any key combinations you would like.

0
Dec 08 '16 at 16:24
source share

For macros: CMD + Shift + 7

0
Sep 13 '17 at 13:37 on
source share

At the moment (version 1.18.0) you can check the keyboard shortcuts by going to File> Settings> Hotkeys. Here you can search for labels associated with comments.

For users who come from Sublime Text or like to have Ctrl + Shift + / , you can make changes from the above option or just install the Microsoft Sublime Text Keymap .

0
Nov 10 '17 at 7:44
source share

on Windows 10, Italian Keyboard, VSC 1.19.1:

Select the lines you want to comment on and press "Ctrl + ΓΉ"

0
Dec 21 '17 at 17:59 on
source share

visual studio 2017 we do a: Comment Selection

 Ctrl+K, Ctrl+C 

press Ctrl + K to get a shortcut. press Ctrl + C to confirm http://visualstudioshortcuts.com/2017/

0
Dec 23 '17 at 0:00
source share



All Articles