mirror of
https://github.com/gryf/snipmate.vim.git
synced 2025-12-19 12:28:11 +01:00
Completely replaced command-based snippets with a new, easier to read/maintain syntax. Also added a python script to make it easier to migrate.
This commit is contained in:
75
snippets/python.snippets
Normal file
75
snippets/python.snippets
Normal file
@@ -0,0 +1,75 @@
|
||||
# #!/usr/bin/python
|
||||
snippet #!
|
||||
#!/usr/bin/python
|
||||
|
||||
# While
|
||||
snippet wh
|
||||
while ${1:condition}:
|
||||
${2:# code...}
|
||||
# New Class
|
||||
snippet cl
|
||||
class ${1:ClassName}(${2:object}):
|
||||
"""${3:docstring for $1}"""
|
||||
def __init__(self, ${4:arg}):
|
||||
${5:super($1, self).__init__()}
|
||||
self.$4 = $4
|
||||
${6}
|
||||
# New Function
|
||||
snippet def
|
||||
def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
|
||||
"""${3:docstring for $1}"""
|
||||
${4:pass}
|
||||
# New Method
|
||||
snippet defs
|
||||
def ${1:mname}(self, ${2:arg})):
|
||||
${3:pass}
|
||||
# New Property
|
||||
snippet property
|
||||
def ${1:foo}():
|
||||
doc = "${2:The $1 property.}"
|
||||
def fget(self):
|
||||
${3:return self._$1}
|
||||
def fset(self, value):
|
||||
|
||||
# Self
|
||||
snippet .
|
||||
self.
|
||||
# Try/Except
|
||||
snippet try
|
||||
try:
|
||||
${1:pass}
|
||||
except ${2:Exception}, ${3:e}:
|
||||
${4:raise $3}
|
||||
# Try/Except/Else
|
||||
snippet trye
|
||||
try:
|
||||
${1:pass}
|
||||
except ${2:Exception}, ${3:e}:
|
||||
${4:raise $3}
|
||||
else:
|
||||
${5:pass}
|
||||
# Try/Except/Finally
|
||||
snippet tryf
|
||||
try:
|
||||
${1:pass}
|
||||
except ${2:Exception}, ${3:e}:
|
||||
${4:raise $3}
|
||||
finally:
|
||||
${5:pass}
|
||||
# Try/Except/Else/Finally
|
||||
snippet tryef
|
||||
try:
|
||||
${1:pass}
|
||||
except ${2:Exception}, ${3:e}:
|
||||
${4:raise $3}
|
||||
else:
|
||||
${5:pass}
|
||||
finally:
|
||||
${6:pass}
|
||||
# if __name__ == '__main__':
|
||||
snippet ifmain
|
||||
if __name__ == '__main__':
|
||||
${1:main()}
|
||||
# __magic__
|
||||
snippet _
|
||||
__${1:init}__${2}
|
||||
Reference in New Issue
Block a user