Fixed expandtabs. Was broken at the beginning of the line. Now it is broken in the middle of the line

This commit is contained in:
Holger Rapp 2009-07-30 08:08:36 +02:00
parent 51f462bbde
commit ac163993a9
2 changed files with 9 additions and 6 deletions

View File

@ -25,8 +25,8 @@ class ${1:MyClass}(${2:object}):
def __init__( self${4/([^,])?(.*)/(?1:, )/}${4:arg} ):
"""
TODO: Fill me in
${4/.+/(?0:\n)/}${4/(\A\s*,\s*\Z)|,?\s*([A-Za-z_][A-Za-z0-9_]*)\s*(=[^,]*)?(,\s*|$)/(?2:\t\t$2 - describe me here\n)/g}\t\t"""
${2/object$|(.+)/(?1:\t\t$0.__init__\(self\)\n\n)/}${4/(\A\s*,\s*\Z)|,?\s*([A-Za-z_][A-Za-z0-9_]*)\s*(=[^,]*)?(,\s*|$)/(?2:\t\tself._$2 = $2\n)/g}
${4/.+/(?0:\n)/}${4/(\A\s*,\s*\Z)|,?\s*([A-Za-z_][A-Za-z0-9_]*)\s*(=[^,]*)?(,\s*|$)/(?2: $2 - describe me here\n)/g} """
${2/object$|(.+)/(?1: $0.__init__\(self\)\n\n)/}${4/(\A\s*,\s*\Z)|,?\s*([A-Za-z_][A-Za-z0-9_]*)\s*(=[^,]*)?(,\s*|$)/(?2: self._$2 = $2\n)/g}
endsnippet
snippet .
@ -48,7 +48,7 @@ endsnippet
snippet rwprop "Read write property" b
def ${1:property}():
${2/.+/(?0:""")/}${2:The RW property $1}${2/.+/(?0:"""\n\t\t)/}def fget(self):
${2/.+/(?0:""")/}${2:The RW property $1}${2/.+/(?0:"""\n )/}def fget(self):
return self._$1$0
def fset(self, value):
self._$1 = value

View File

@ -51,7 +51,10 @@ class Snippet(object):
if vim.eval("&expandtab") == '1':
ts = int(vim.eval("&ts"))
v = v.expandtabs(ts)
# expandtabs will not work for us, we have to replace all tabstops
# so that indent is right at least. tabs in the middle of the line
# will not be expanded correctly
v = v.replace('\t', ts*" ")
if parent is None:
return SnippetInstance(StartMarker(start), indent, v)