Skip to content

Instantly share code, notes, and snippets.

@co89757
Last active April 17, 2019 06:27
Show Gist options
  • Save co89757/22bfee73cda974486a21b34f9b48c718 to your computer and use it in GitHub Desktop.
Save co89757/22bfee73cda974486a21b34f9b48c718 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment