garbas/vim-snipmate

Mirror is not work on self-defined snippet

chan15 opened this issue · 1 comments

I created a php snippet in ~/.vim/snippets/php.snippets, the code is like

snippet eipuitext
	$${1} = new Text('${0}');
	$myForm->addElement($$1);

but it won't work, there will be only $ in addElement()

Define the snippet as follows, and it will work.

snippet eipuitext
    \$${1:} = new Text('${0}');
    \$myForm->addElement(\$$1);

There are two differences. Firstly, all dollar signs that are to be in the expanded text are escaped with backslashes. Secondly, the first tabstop has a colon to specify an empty placeholder. This second change is unnecessary if you use version 1 of the snippet parser. Version 0, however, requires that a placeholder be specified for any mirror to work. (In version 1, the braces around the stops are not needed either.)