Home > Back-end >  Is there a shortcut to comment multiple lines in python using VS Code?
Is there a shortcut to comment multiple lines in python using VS Code?

Time:09-27

Instead of indivually typing out a hash tag in front of each line, is there a way to select a block of code and comment/uncomment everything by only pressing a couple shortcut keys?

CodePudding user response:

Select all of the lines and do one of the following:

  • Windows: Ctrl /
  • Mac: Cmd /

All shortcuts:

CodePudding user response:

All you need to do is select that code block with your mouse, then press the following key combination:

Ctrl K then press Ctrl C if you’re using Windows
Command K then press Command C if you’re on a Mac

You can also use:

Ctrl / to comment and uncomment lines of Python code on Windows.
Command / to comment and uncomment multiple lines of Python code on Mac.

  • Related