简体   繁体   English

用于在选项卡中插入片段的vim片段快捷方式

[英]vim snipmate shortcut for inserting snip inside tab

I have been using Vim with the snipMate plugin for creating HTML code. 我一直在使用Vim和snipMate插件来创建HTML代码。 This is the code I want to type quickly: 这是我要快速键入的代码:

<ul>
    <li><a href="this.html">that</a></li>
</ul>

So I start in insert mode typing ul Tab li Tab but then when I try typing a tab to create the link snippet it doesn't work, it moves to the end of the line (which is what the snippet says to do). 于是,我开始在插入模式下输入ul 标签 li 选项卡 ,但后来当我尝试输入a 标签来创建链接片断这是行不通的,它移动到该行的结束(这是段说怎么做)。

I have tried to escape the snip by pressing Esc , but once I enter insert mode Tab still takes me to the end of the line. 我试图通过按Esc来逃避该片段,但是一旦进入插入模式, Tab仍将我带到行尾。 Currently the best way I can get it to work is by accepting the Tab to the end of the line, moving backwards then insert. 目前,使它起作用的最佳方法是接受Tab到行尾,向后移动然后插入。 Is this method the most efficient way of doing this? 这种方法是最有效的方法吗? How do you escape a snippet? 您如何逃脱摘要?

I also have the following snippet for a in html.snippets 我也有下面的代码片段ahtml.snippets

snippet a
    <a href="${1:#}">${2:$1}</a>${3}

Pressing a Tab puts me after the href=" and I type this.html , the snippet puts this.html before the </a> . When I press Tab and then want to type over the second this.html (like in TextMate) and so I type that , but it leaves thathis.html ? a 标签把我的后href="和I型this.html中,摘录把this.html的前</a> 。当我按下Tab键,然后要输入在第二this.html (如在TextMate中)所以我输入了that ,但是留下了那thathis.html

Snipmate does not support nested snippets. 代码段不支持嵌套代码段。 I suggest you try UltiSnips . 我建议您尝试UltiSnips

I think you might just be after: 我想您可能只是在追求:

snippet a
    <a href="${1:#}">${2}</a>${3}

Also, if the cursor moving to the end of the line is annoying, drop ${3} , or if you wanted to edit the tag content in hindsight (after moving to the end of the line), use c i t ( change inner tag ) 另外,如果将光标移动到该行的结尾是烦人,下降${3}或者如果你想编辑在事后的标签内容(移动到行结束后),使用C I T( 改变内标签

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

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