Python Forum

Full Version: Visual studio shortcut key to add comments to python code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi,

I am using Visual Studio 2019 as my IDE for writing python codes.
I was wondering how an earth do you add comments to a block of code?
I can't see any options in the menu bar.

Thanks!
# This is a one line comment in Visual studio. The below one is multiline
"""
This is a comment
This is another comment
"""
Basically, when you want a comment, the best way is to think of it as hashtag. You put # on the line of code you want the interpreter to ignore.
What I meant was is there a button in Visual Studio to comment out a block of code in python?
select a block of code and press ctrl+/
In mac, select a block of code and press command KC
https://npsedu-my.sharepoint.com/persona...origin=717
I have windows and i tried ctrl + / and it didn't do anything Confused
Try Ctrl K C
(May-24-2020, 10:07 AM)mp3909 Wrote: [ -> ]I have windows and i tried ctrl + / and it didn't do anything
Probably you are doing something wrong. Attached is screenshot from VS Code under Windows, EDIT menu.
As you can see shortcut for Toggle Line Comment is Ctrl + /
and shortcut for Toggle Block Comment is Shift + Alt + A

[attachment=886]
Pages: 1 2