简体   繁体   English

vim snipMate:在代码段中展开代码段

[英]vim snipMate: expand snippet within a snippet

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. 使用vim-snipmate我有以下问题:如果我尝试在代码段中展开代码段,则snipmate会将我带到当前代码段的下一个占位符,而不是展开新代码段。

eg: If you press tab in the following situation: 例如:如果在以下情况下按tab键:

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 最好的祝福

The original snipMate did not support recursive snippet expansion. 原始的snipMate不支持递归代码段扩展。 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 . 一个现代的替代品(虽然需要Python)是UltiSnips As far as I know, this one does support snippets within snippets. 据我所知,这个支持片段内的片段。

lh-cpp and mu-template support snippets within snippets, and even snippets that expand snippets (eg switch snippet relies on case snippet). lh-cppmu-template支持片段内的片段,甚至是扩展片段的片段(例如, switch片段依赖于case片段)。

However, snippets syntax has nothing to do with the one from snipMate and consorts. 但是,片段语法与snipMate和consorts中的语法无关。 And the placeholders system used is the old-school one. 使用的占位符系统是老派系统。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM