Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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