How to comment multiple lines in Visual Studio Code?

后端 未结 30 1865
感情败类
感情败类 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:03

    You can see all available keybindings on the official documentation.

    Here's the relevant 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 select the lines you want to comment first, then execute above shortcut, i.e. ⌘/ on osx Ctrl/ on Windows.

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

    For my keyboard layout it's Ctrl + § for:

    //
    //
    //
    

    And Shift + Alt + A for:

    /*
    ...
    */
    
    0 讨论(0)
  • 2020-11-28 01:03

    In windows you need to press ctrl + / in mac you can do + / to make multiple comment

    // public function index()
    // {
    //     $badgeIcon = BadgeIcon::all();
    //     return $this->showAll($badgeIcon);
    // }
    

    Then if you want to un-comment then select the lines again and then press ctrl + /(in windows) again + /(in mac).

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

    CTRL + SHIFT + A for CSS multiline

    • Ubuntu 16
    • VSCode Version 1.17.2
    0 讨论(0)
  • In the new version of VSCODE ( version 1.26.1)

    1. Go to File > preferences > Keyboard Shortcuts
    2. Search for comment Double click the existing shortcut 'keybinding`
    3. And press the new keyboard shortcut in my case ctrl + shfit + /

    You can assign any shortcuts you want. Hope it helps.

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

    For me it was ctrl + ' (I am using a swedish layout for the keyboard). Hope that helps anyone.

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