vim-vsnip icon indicating copy to clipboard operation
vim-vsnip copied to clipboard

Space within an element breaks the snippet flow

Open ubitux opened this issue 3 years ago • 1 comments

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.

ubitux avatar Aug 27 '22 22:08 ubitux

Sorry. It's documented.

https://github.com/hrsh7th/vim-vsnip/blob/master/doc/vsnip.txt#L251

hrsh7th avatar Oct 07 '22 10:10 hrsh7th