Shortcut to comment out multiple lines with Python Tools for Visual Studio

Question:

What is the shortcut to comment out multiple lines with Python Tools for Visual Studio?

Asked By: Johan Råde

||

Answers:

On python the only way is """ ... """, practically just a string.

Answered By: sorin

CTRL+K then CTRL+C adds the # in VS for selected lines.
CTRL+K then CTRL+U removes the # in VS for selected lines.

Answered By: manojlds

All you need to do is select the block of code and type ctrl+1.
You should be all set!

To make the comment of a block, it is a sequence of keys: Ctrl-K + Ctrl+C and to un-comment Ctrl-K + Ctrl-U.

Here are some other very useful keys for Python:

Short Keys for Visual Studio 2015 - Python

Answered By: Pierre Ghislain

If you want to comment out any line in python (when using visual code) then the shortcut is: Ctrl + / (control button plus forward slash)

Answered By: Priya Kulkarni

The easiest way to achieve this is to highlight all the previous written code you wish to comment out, then control KC. You will not experience any bugs or altered code during the process. Sometimes Other methods just
don’t work.

Answered By: Kevin Cook

To comment or uncomment
Ctrl + /

Answered By: Julien
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.