VIM:插入空液体标签的快捷方式?

发布于 2024-12-22 02:56:10 字数 460 浏览 2 评论 0原文

我正在将我的博客迁移到 Jekyll 并使用 MacVim 来撰写我的帖子。我注意到我写的标签很多看起来像这样:

{% highlight bash %}
chmod -R g+w test
{% endhighlight %}

甚至...

{{ content }}

是否有插入 {{ }}{% %} 的快捷方式标签?

注意:我对 Vim 还很陌生,所以非常感谢您的帮助。我安装了 Tim Pope 的 Liquid 插件 以及环绕插件。

I'm migrating my blog to Jekyll and using MacVim to write my posts. I notice that I'm writing tags that look like this a lot:

{% highlight bash %}
chmod -R g+w test
{% endhighlight %}

or even...

{{ content }}

Is there a shortcut to insert the {{ }} or {% %} tags?

Note: I'm fairly new to Vim so any help is appreciated. I have Tim Pope's Liquid plugin installed as well as the surround plugin.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

马蹄踏│碎落叶 2024-12-29 02:56:10

您可能想看看 Tim Pope 的 ragtag。它为 {{ foo }} 提供了 = ,为 {% foo % 提供了 - 等映射}

如果您不想要ragtag,并且由于您已经安装了环绕声,您可能需要创建自己的映射。我建议您创建一个 ~/.vim/after/ftplugin/liquid.vim 并输入以下内容:

let b:surround_45 = "{% \r %}"
let b:surround_61 = "{{ \r }}"

这将为 = 和 < 创建环绕映射code>- 就像 ragtag 一样。

You may want to take a look at ragtag by Tim Pope. It provides mappings like <c-x>= for {{ foo }} and <c-x>- for {% foo %}.

If you do not want ragtag and since you have surround installed you may want to create your own mappings. I suggest you create a ~/.vim/after/ftplugin/liquid.vim and put in the following:

let b:surround_45 = "{% \r %}"
let b:surround_61 = "{{ \r }}"

This will create surround mappings for <c-s>= and <c-s>- just like ragtag.

剑心龙吟 2024-12-29 02:56:10

您始终可以使用键盘映射,例如

:imap I{ {{}}<esc>hhi

使用它,如果您在插入模式下键入 I{ ,它将插入 {{}} 然后切换回正常模式将光标移回然后第一个 } 返回插入模式。

华泰

You can always use keyboard maps, like

:imap I{ {{}}<esc>hhi

With it if you type I{ in insert mode it will insert {{}} then switches back to normal mode moves the cursor back to the 1st } then goes to insert mode back.

HTH

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文