pycharm-like-snippets 一个 vs code python snippets 扩展

因为很喜欢 pycharm 上的 输入 .print 按回车后,会自动把前面的表达式括起来,所以花了点时间,把 pycharm 上有的一些 snippets 做到 vs code 扩展中了(为了粗包饺子那味)。不过,那个功能因回车和vs code 原有的机制冲突,所以把想做的功能做成了按 alt+p 后,把光标前面的表达式括起来。

vs code 中,可以通过关键字 pycharm-like-snippets 搜到。

github 链接如下:

目前支持以下 snippets(代码片段):

prefix description
main main script entry point
compd Dict comprehension
compdi Dict comprehension with if
compg Generator comprehension
compgi Generator comprehension with if
compl List comprehension
compli List comprehension with if
comps Set comprehension
compsi Set comprehension with if
iter Iterate (for … in …)
itere Iterate (for … in enumerate)
prop Property getter
props Property getter/setter
propsd Property getter/setter/deleter
deff python functions
adef python async functions
klass python class without inheritance
klassi python class with inheritance
forr python for x in range(y)
afor python async for in aiterables
openw python open file by with statement

欢迎大家来试一试,并提供建议,也可以进行 pr, 增加常用的 snippets !!!

3 个赞

有点像 Go 在 vscode 中的味道:+1: