Looking for a Python extension for auto-generated comment header #226
-
Hello fellow VS Code users, For instance:
Extension would auto-generate the #--- when you type "def". I'm sure this wouldn't be difficult to create if I had to but haven't looked into how to do that yet. Thanks for any suggestions! -MF |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
I am not aware of such an extension. Maybe @luabud knows. |
Beta Was this translation helpful? Give feedback.
-
One extension I personally use for adding comments to my functions is the autoDocstring one. After you function definition, if you add |
Beta Was this translation helpful? Give feedback.
-
Thanks! I’m actually using this. It’s pretty nice 😊 We have a thing here where there should be some comments above the method as well and while I realize docstring is the python way I want to generate a block of standard comments above the method. I am guessing I could write a simple plugin to do it it’s just been low on my priority list. LOL
Get Outlook for iOS<https://aka.ms/o0ukef>
…________________________________
From: Luciana Abud ***@***.***>
Sent: Wednesday, November 23, 2022 6:45:13 PM
To: microsoft/vscode-discussions ***@***.***>
Cc: Matt Fury ***@***.***>; Author ***@***.***>
Subject: Re: [microsoft/vscode-discussions] Looking for a Python extension for auto-generated comment header (Discussion #226)
One extension I personally use for adding comments to my functions is the autoDocstring <https://marketplace.visualstudio.com/items?itemName=njpwerner.autodocstring> one. After you function definition, if you add """ it will suggest to auto generate the docstrings for you, and then you can just fill in the placeholders with the info you'd like. It's also nice that it lets you just start typing and then hit tab to move to the next placeholder 😊
[image]<https://user-images.githubusercontent.com/45497113/203664369-e8ec920d-5bdf-4f80-b520-2e9be78058c1.png>
—
Reply to this email directly, view it on GitHub<#226 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AWQE5K77USI36FMVDZ5G7RTWJ2UATANCNFSM6AAAAAAR3Y7ZJU>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Ohh I see. I'm wondering if you could use snippets for this? If you run the "Snippets: Configure User Snippets" command, you could create one for Python only that could do something like this:
This would make it VS Code suggest the snippet once you start typing "def", and then if you accept it, it will add the comments above it. You can play around with the $N markers to enable which input you want to fill in first. This way you can just start typing right after you insert the snippet and then hit tab to move to the next input |
Beta Was this translation helpful? Give feedback.
-
This is awesome. I think you’re on to something. I figured it had to be reasonable but hadn’t look where to start. Thank you. ✌🏼
Get Outlook for iOS<https://aka.ms/o0ukef>
…________________________________
From: Luciana Abud ***@***.***>
Sent: Thursday, November 24, 2022 1:27:18 PM
To: microsoft/vscode-discussions ***@***.***>
Cc: Matt Fury ***@***.***>; Author ***@***.***>
Subject: Re: [microsoft/vscode-discussions] Looking for a Python extension for auto-generated comment header (Discussion #226)
Ohh I see. I'm wondering if you could use snippets <https://code.visualstudio.com/docs/editor/userdefinedsnippets#_create-your-own-snippets> for this? If you run the "Snippets: Configure User Snippets" command, you could create one for Python only that could do something like this:
"Add comments to functions": {
"prefix": "def",
"body": [
"# -------------------------------------",
"# $1 ",
"# -------------------------------------",
"def $2"
],
"description": "Add comments to functions"
}
This would make it VS Code suggest the snippet once you start typing "def", and then if you accept it, it will add the comments above it. You can play around with the $N markers to enable which input you want to fill in first. This way you can just start typing right after you insert the snippet and then hit tab to move to the next input
—
Reply to this email directly, view it on GitHub<#226 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AWQE5KYMUN7OTF46PB76ERLWJ6XQNANCNFSM6AAAAAAR3Y7ZJU>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
Ohh I see. I'm wondering if you could use snippets for this? If you run the "Snippets: Configure User Snippets" command, you could create one for Python only that could do something like this:
This would make it VS Code suggest the snippet once you start typing "def", and then if you accept it, it will add the comments above it. You can play around with the $N markers to enable which input you want to fill in first. This way you can just …