Python Forum
Visual studio shortcut key to add comments to python code - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: News and Discussions (https://python-forum.io/forum-31.html)
+--- Thread: Visual studio shortcut key to add comments to python code (/thread-26891.html)

Pages: 1 2


Visual studio shortcut key to add comments to python code - mp3909 - May-17-2020

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!


RE: add comments to python code - Axel_Erfurt - May-17-2020

https://www.zentut.com/python-tutorial/python-comments/


RE: add comments to python code - pyzyx3qwerty - May-18-2020

# This is a one line comment in Visual studio. The below one is multiline
"""
This is a comment
This is another comment
"""



RE: add comments to python code - pav1983 - May-23-2020

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.


RE: add comments to python code - mp3909 - May-23-2020

What I meant was is there a button in Visual Studio to comment out a block of code in python?


RE: add comments to python code - buran - May-23-2020

select a block of code and press ctrl+/


RE: add comments to python code - pyzyx3qwerty - May-24-2020

In mac, select a block of code and press command KC
https://npsedu-my.sharepoint.com/personal/aarav201929_npshsr_com/_layouts/15/Doc.aspx?sourcedoc={9cf9e60b-3760-4bc9-91eb-617aeb970976}&action=view&hh=1&wd=target%28Untitled%20Section.one%7C77e55f3a-4a39-43fd-9b7a-f2703ed72457%2F%29&wdorigin=717


RE: add comments to python code - mp3909 - May-24-2020

I have windows and i tried ctrl + / and it didn't do anything Confused


RE: add comments to python code - pyzyx3qwerty - May-24-2020

Try Ctrl K C


RE: add comments to python code - buran - May-24-2020

(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]