Python Forum
Visual studio shortcut key to add comments to python code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Visual studio shortcut key to add comments to python code
#1
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!
Reply
#2
https://www.zentut.com/python-tutorial/python-comments/
Reply
#3
# This is a one line comment in Visual studio. The below one is multiline
"""
This is a comment
This is another comment
"""
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply
#4
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.
Reply
#5
What I meant was is there a button in Visual Studio to comment out a block of code in python?
Reply
#6
select a block of code and press ctrl+/
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#7
In mac, select a block of code and press command KC
https://npsedu-my.sharepoint.com/persona...origin=717
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply
#8
I have windows and i tried ctrl + / and it didn't do anything Confused
Reply
#9
Try Ctrl K C
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply
#10
(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

   
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Survey on Python comments sgrey 1 543 Feb-02-2024, 11:23 PM
Last Post: charllykorpa
  Visual Studio for Python 357mag 3 55,817 Jul-11-2023, 08:15 AM
Last Post: PyDan
  Creating Python scripts in Visual Studio Code Sanjish 4 2,535 Dec-22-2020, 12:32 PM
Last Post: snippsat
  visual studio code python how to get source code of import module definitian umen 2 3,865 Jun-13-2020, 06:20 PM
Last Post: umen
  How to create a shortcut of your python program on your phone screen (using Q3Python) Alexx 0 1,574 May-20-2020, 06:10 PM
Last Post: Alexx
  Python Shell As Preferred Mode For Integrated Terminal In Visual Studio Code adt 4 3,980 Sep-07-2019, 06:00 PM
Last Post: adt
  Trying to make a shortcut key to execute program 357mag 1 1,789 Apr-12-2019, 08:36 PM
Last Post: Yoriz
  Visual studio and Afzal 0 1,759 Feb-20-2019, 11:10 AM
Last Post: Afzal
  Python in Visual Studio “15” Preview snippsat 5 22,073 Oct-17-2016, 06:43 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020