diff --git a/UltiSnips/all.snippets b/UltiSnips/all.snippets index 437c4d9..fe6b9ae 100644 --- a/UltiSnips/all.snippets +++ b/UltiSnips/all.snippets @@ -10,14 +10,15 @@ c = '#' cs = vim.eval("&commentstring") if len(cs) == 3: c = cs[0] +snip.locals["c"] = c -res = (len(t[1])+4)*c + '\n' + c + ' '`${1:content}`!p -c = '#' -cs = vim.eval("&commentstring") -if len(cs) == 3: - c = cs[0] +snip.rv = (len(t[1])+4)*c +snip.locals["bar"] = snip.rv +snip += c + ' '`${1:content}`!p +c = snip.locals["c"] -res = ' ' + c + '\n' + (len(t[1])+4)*c` +snip.rv = ' ' + c +snip += snip.locals["bar"]` $0 endsnippet @@ -27,15 +28,17 @@ c = '#' cs = vim.eval("&commentstring") if len(cs) == 3: c = cs[0] +snip.locals["c"] = c +snip.locals["bar"] = 75*c -res = 75*c + '\n' + c + " "+ (71-len(t[1]))/2*' ' +snip.rv = snip.locals["bar"] +snip += c + " " + (71-len(t[1]))/2*' ' `${1:content}`!p -c = '#' -cs = vim.eval("&commentstring") -if len(cs) == 3: - c = cs[0] +c = snip.locals["c"] -a = 71-len(t[1]); res = (a/2 + a%2) * " " + " " + c + '\n' + 75*c` +a = 71-len(t[1]) +snip.rv = (a/2 + a%2) * " " + " " + c +snip += snip.locals["bar"]` $0 endsnippet diff --git a/UltiSnips/c.snippets b/UltiSnips/c.snippets index fae8539..d58c63a 100644 --- a/UltiSnips/c.snippets +++ b/UltiSnips/c.snippets @@ -9,7 +9,7 @@ snippet def "#ifndef … #define … #endif" endsnippet snippet inc "#include "" (inc)" -#include "${1:`!p res=fn.split('.')[-2]+'.h'`}" +#include "${1:`!p snip.rv = snip.basename + '.h'`}" endsnippet snippet Inc "#include <> (Inc)" @@ -46,11 +46,11 @@ endsnippet snippet once "Include header once only guard" #ifndef ${1:`!p -if not len(cur): +if not len(snip.c): import random, string - name = re.sub(r'[^A-Za-z0-9]+','_', fn).upper() + name = re.sub(r'[^A-Za-z0-9]+','_', snip.fn).upper() rand = ''.join(random.sample(string.ascii_letters+string.digits, 8)) - res = ('%s_%s' % (name,rand)).upper()`} + snip.rv = ('%s_%s' % (name,rand)).upper()`} #define $1 ${0} @@ -85,8 +85,7 @@ printf("${1:%s}\n"${1/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2 endsnippet snippet st "struct" -struct ${1:`!p if fn != "": res = fn.split(".")[-2].lower()+"_t" -else: res = "name"`} +struct ${1:`!p snip.rv = (snip.basename or "name") + "_t"`} { ${0:/* data */} }; diff --git a/UltiSnips/cpp.snippets b/UltiSnips/cpp.snippets index 40a8068..32e5d14 100644 --- a/UltiSnips/cpp.snippets +++ b/UltiSnips/cpp.snippets @@ -8,11 +8,7 @@ ${1:v}${1/^.*?(-)?(>)?$/(?2::(?1:>:.))/}begin(), $1${1/^.*?(-)?(>)?$/(?2::(?1:>: endsnippet snippet cl "class .. (class)" -class ${1:`!p -if len(fn): - res = fn.split(".")[-2].lower()+ '_t' -else: - res = "name"`} +class ${1:`!p snip.rv = snip.basename or "name"`} { public: ${1/(\w+).*/$1/} (${2:arguments}); @@ -24,9 +20,7 @@ private: endsnippet snippet ns "namespace .. (namespace)" -namespace${1/.+/ /m}${1:`!p -if len(fn): res = fn.split(".")[-2].lower() -else: res ="name"`} +namespace${1/.+/ /m}${1:`!p snip.rv = snip.basename or "name"`} { $0 }${1/.+/ \/* /m}$1${1/.+/ *\/ /m} diff --git a/UltiSnips/help.snippets b/UltiSnips/help.snippets index 86b6618..0a002e1 100644 --- a/UltiSnips/help.snippets +++ b/UltiSnips/help.snippets @@ -3,32 +3,33 @@ snippet sec "Section marker" b ============================================================================= ${1:SECTION}`!p -file_start = fn.split('.')[0] +file_start = snip.fn.split('.')[0] sec_name = t[1].strip("1234567890. ").lower().replace(' ', '-') -res = ("*%s-%s*" % (file_start, sec_name)).rjust(77-len(t[1]))` +snip.rv = ("*%s-%s*" % (file_start, sec_name)).rjust(77-len(t[1]))` $0 endsnippet snippet ssec "Sub section marker" b ${1:Subsection}`!p -file_start = fn.split('.')[0] +file_start = snip.fn.split('.')[0] sec_name = t[1].strip("1234567890. ").lower().replace(' ', '-') sec_title = ("*%s-%s*" % (file_start, sec_name)).rjust(77-len(t[1])) -res = sec_title + "\n" + "-"*len(t[1])` +snip.rv = sec_title +snip += "-"*len(t[1])` $0 endsnippet snippet sssec "Subsub Section marker" b - ${1:SubSubsection}:`!p +${1:SubSubsection}:`!p file_start = fn.split('.')[0] sec_name = t[1].strip("1234567890. ").lower().replace(' ', '-') sec_title = ("*%s-%s*" % (file_start, sec_name)).rjust(77-len(t[1])) -res = sec_title` +snip.rv = sec_title` $0 endsnippet diff --git a/UltiSnips/html.snippets b/UltiSnips/html.snippets index 2cfd60b..bb1a585 100644 --- a/UltiSnips/html.snippets +++ b/UltiSnips/html.snippets @@ -112,12 +112,12 @@ endsnippet # HTML TAGS # ############# snippet input "Input with Label" - + endsnippet snippet input "XHTML " - + endsnippet @@ -143,15 +143,12 @@ snippet mailto "XHTML " endsnippet snippet base "XHTML " - + endsnippet snippet body "XHTML " $0 @@ -164,14 +161,12 @@ snippet div "XHTML
" endsnippet snippet form "XHTML
" - + $0 -

+

endsnippet @@ -181,21 +176,18 @@ endsnippet snippet head "XHTML " - - ${1:`!p if len(fn): - res = fn.split('.')[-2] -else: - res = "Page Title"`} + + ${1:`!p snip.rv = snip.basename or "Page Title"`} $0 endsnippet snippet link "XHTML " - + endsnippet snippet meta "XHTML " - + endsnippet snippet scriptsrc "XHTML