co89757
4/17/2019 - 5:55 AM

Ultisnips Advanced Tricks

global !p
def complete(t, opts):
	if t:
		opts = [o[len(t):] for o in opts if o.startswith(t)]
	if len(opts) == 1:
	  return opts[0]
	return "(" + "|".join(opts) + ")"
endglobal

# snippt option b means only enable at begin of line
# mirror and transformation ${1/regex/replace/} use $1,2,.. for regex group reference
snippet t "html tag" b 
<${1:div}>
	$2
<${1/(\w+).*/$1/}>
endsnippet 
# Shell expansion use ``, vimL expansion using `!v ...` , python expansion using `!p ...`
snippet todo "TODO" b
// TODO ${1:desc} <`!v strftime('%c')` `echo $USER`> 
endsnippet
# regex trigger using option r, only expands when trigger matches regex
snippet '^ st' "simple" r
...
endsnippet