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

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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?
:unlet g:snipPos will disrupt the current snippet expansion by clearing the plugin's context.
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.

2 Comments

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.
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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.