简体   繁体   中英

vim snipmate shortcut for inserting snip inside tab

I have been using Vim with the snipMate plugin for creating HTML code. 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).

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

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 ?

Snipmate does not support nested snippets. I suggest you try 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 )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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