Skip to content

Instantly share code, notes, and snippets.

@brenopacheco
Created December 7, 2020 23:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brenopacheco/9ca5c7c7e8cc76cccde33b30a0dd1184 to your computer and use it in GitHub Desktop.
Save brenopacheco/9ca5c7c7e8cc76cccde33b30a0dd1184 to your computer and use it in GitHub Desktop.
convert yasnippet to vsnip
" Roughly converts yasnippet format snippets to vsnip (vs code like) snippets
" performs in-place substitutions. make sure not to use autopairs plugin.
"
" example:
"
" # -*- mode: snippet -*-
" # name: equals
" # key: eq
" # --
" public boolean equals(${1:Class} other) {
" $0
" }
"
" will translate to:
"
" "equals": {
" "prefix": "eq",
" "description": "eq",
" "body": [
" "public boolean equals(${1:Class} other) {",
" "$0",
" "}"
" ]
" },
function Convert() abort
g/^$/d
2norm 0df:r"A": {
3norm 0df:xi"prefix": "
3norm 0A",
3norm yyp
4s/prefix/description
5s/.*/"body": [
6,$norm I"
6,$norm A",
1d
2,$>
1,$>
5,$>
$norm $xo]
$norm <o},
$norm <
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment