1

Using vim-snipmate I have the following problem: If I try to expand a snippet within a snippet, snipmate takes me to the next placeholder of the current snippet instead of expanding the new snippet.

e.g.: If you press tab in the following situation:

for (i = 0; i < 10; i++) {
    ifi<press tab here>
}

I would expect:

for (i = 0; i < 10; i++) {
    if (<cursor position>) ;
}

but what I get is the following:

for (i = 0; i < 10; i++) {
    ifi
}<cursor position>

Is there a way to expand snippets within snippets or at least a way to suppress going to the next placeholder?

best regards

crs
  • 501
  • 1
  • 4
  • 12

2 Answers2

2

The original snipMate did not support recursive snippet expansion. Apparently, the fork doesn't, neither. It wouldn't hurt to ask on the project's issue tracker for such support.

A modern alternative (that requires Python though) is UltiSnips. As far as I know, this one does support snippets within snippets.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
  • Thanks for your answer, I will definitely take a look at UltiSnips. But besides another plugin, is it possible to stop the current "tab through the snippet"-process in snipMate? – crs Apr 14 '14 at 19:39
  • 1
    `:unlet g:snipPos` will disrupt the current snippet expansion by clearing the plugin's context. – Ingo Karkat Apr 15 '14 at 06:11
1

lh-cpp and mu-template support snippets within snippets, and even snippets that expand snippets (e.g. switch snippet relies on case snippet).

However, snippets syntax has nothing to do with the one from snipMate and consorts. And the placeholders system used is the old-school one.

Luc Hermitte
  • 31,979
  • 7
  • 69
  • 83
  • Thanks for your answer, but it looks like that both of the plugins you posted don't support snippets for python/html snippets. Unfortunately, the latter is a criterion for excluding for me. – crs Apr 14 '14 at 19:43
  • mu-template perfectly supports html/python/whatever. It's just that if the snippets don't exist yet, you'll have to write them (or to send me a draft of what is missing) – Luc Hermitte Apr 15 '14 at 09:24