How to comment multiple lines in Visual Studio Code?

后端 未结 30 1864
感情败类
感情败类 2020-11-28 00:23

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 Co

相关标签:
30条回答
  • 2020-11-28 01:13

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

    You can customize the keyboard shortcuts by going int the "Tools" menu and selecting "Options". Then select "Keyboard" from the "Environment" branch. From there you can bind the Edit.CommentSelection and Edit.UncommentSelection commands to whichever keyboard shortcuts you'd like.

    0 讨论(0)
  • 2020-11-28 01:14

    For windows, the default key for multi-line comment is Alt + Shift + A

    For windows, the default key for single line comment is Ctrl + /

    0 讨论(0)
  • 2020-11-28 01:14

    If you are using VSCode in a linux environment, then you can comment multiple lines by either:

    Selecting a block of code => then, press Ctrl + Shift + A (Block commenting)

    Or, selecting a block of code => then, press Ctrl + / (Single-line commenting applied to all selected lines)

    Hope this helps.

    0 讨论(0)
  • 2020-11-28 01:14

    Multi-Line Comment in VS Code

    To comment the code select the lines and hit: Alt + Shift + A

    To Uncomment select the commented code and hit: Alt + Shift + A

    0 讨论(0)
  • 2020-11-28 01:16

    In Windows

    Select the lines you want to comment. Then press Ctrl + /

    0 讨论(0)
  • 2020-11-28 01:17

    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.

    0 讨论(0)
提交回复
热议问题