如何在 Vim 中插入 ERB 标签? [英] How do I insert ERB-tags with Vim?

查看:41
本文介绍了如何在 Vim 中插入 ERB 标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Vim 中插入 <% %>?我有 rails.vim.

How do I insert <% %> in Vim? I have rails.vim.

推荐答案

我一直在使用 surround.vim 插件很久了,但不是 rails.vim 插件.事实证明,rails.vim 插件正在为围绕.vim 添加功能,或者搭载它.无论哪种方式,我都以这种方式工作:

I've been using the surround.vim plugin for a long time, but not the rails.vim plugin. Turns out that the rails.vim plugin is adding functionality to surround.vim, or is piggy-backing on it. Either way, I got it working this-a way:

  1. 安装 rails.vim 插件(如果尚未安装),然后打开 ERB 文档.Vim 应该将其识别为 eruby 文件类型.
  2. 如果它不使用 :set filetype=eruby Return 让 Vim 以你的方式看待事物.
  3. 使用 vV 直观地选择一些您想用 ERB 标签换行的文本.
  4. S=S-.(这是大写的 S)
  5. 所选文本应包含在 <%= %><%- %> 块中.
  1. Install the rails.vim plugin if it isn't already, and open an ERB document. Vim should recognize it as a eruby filetype.
  2. If it doesn't use :set filetype=eruby Return to make Vim see things your way.
  3. Visually select some text you want to wrap with the ERB tags using v or V.
  4. Press S= or S-. (That's capital S)
  5. The selected text should be wrapped in a <%= %> or <%- %> block.

我刚刚确认这也适用于列选择模式.

I just confirmed this works in column-selection mode too.

这在 rails.vim 帮助中有记录:从命令模式搜索 :h rails-surround.如果你没有 rails.vim 的帮助,那是因为没有按照说明安装它:

This is documented in the rails.vim help: from the command-mode search for :h rails-surround. And if you don't have the help available for rails.vim, it's because the instructions weren't followed for installing it:

:helptags ~/.vim/doc

rails.vim 插件也需要surround.vim 插件,因此必须事先安装.我在编辑时至少每分钟使用一次该插件的功能.它摇滚.

The rails.vim plugin requires the surround.vim plugin also, so that has to be previously installed. I use that plugin's functionality at least once a minute when I'm editing. It rocks.

这篇关于如何在 Vim 中插入 ERB 标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆