Skip to content

Commit 6d026e3

Browse files
committed
Improve class snippet to format the __init__ args
By pressing tab after entering the __init__ method args, the args are formatted to be assigned as class attributes.
1 parent 140c6f5 commit 6d026e3

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Diff for: README.md

+4
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,7 @@ Thanks!
107107
## Release Notes
108108

109109
See [changelog](CHANGELOG.md) for all changes and releases.
110+
111+
## Troubleshooting
112+
113+
If you experience problems with the auto-formatting of certain snippets, make sure you have the option `editor.tabCompletion` set on `onlySnippets` or `on`.

Diff for: snippets/base.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
"\t\"\"\"${3:docstring for $1.}\"\"\"",
5353
"\tdef __init__(self, ${4:arg}):",
5454
"\t\t${5:super($1, self).__init__()}",
55-
"\t\tself.$4 = $4",
56-
"\t\t$0"
55+
"\t${4/([^,=]+)(?:=[^,]+)?(,\\s*|)/\tself.$1 = $1${2:+\n\t}/g}",
56+
"\n\t$0"
5757
],
5858
"description" : "Code snippet for a class definition."
5959
},

0 commit comments

Comments
 (0)