vim-vsnip
vim-vsnip copied to clipboard
Space within an element breaks the snippet flow
In (C) friendly snippets, we can see the following mal snippet:
"Allocate memory using malloc": {
"prefix": "mal",
"body": [
"${1:int} *${2:v} = malloc(${3:1} * sizeof($1));",
"",
"if (!$2) {",
"\tfprintf(stderr, \"Memory allocation failed!\\n\");",
"\t$4;",
"}",
"$0",
"free($2);"
],
"description": "Allocates memory to a pointer variable using malloc(), then deallocates using free()."
},
For the first item (${1:int}), if need to use a struct type such as struct foobar, the presence of the <SPACE> between struct and foobar will actually prevent jumping to the next item.
I'm not sure if that's a bug or a known limitation, but since this is a very common pattern to use in C I thought it was worth raising it up.
Sorry. It's documented.
https://github.com/hrsh7th/vim-vsnip/blob/master/doc/vsnip.txt#L251