VIM:插入空的 ERB 标签 [英] VIM: insert empty ERB tags

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

问题描述

如何插入空的 ERB 标签并将光标放在其中?类似于使用环绕插件环绕,但没有环绕.

How can I insert empty ERB tags and put cursor inside it? It is similar to surrounding with surround plugin, but there is nothing to surround.

例如,从这个:

bla|bla

我想要这个:

bla<%= | %>bla

推荐答案

我会使用 Tim Pope 的环绕插件来完成这个.

I would use Tim Pope's surround plugin to accomplish this.

给你添加以下内容~/.vim/after/ftplugin/erb.vim

Add the following to you ~/.vim/after/ftplugin/erb.vim

let b:surround_{char2nr('=')} = "<%= 
 %>"
let b:surround_{char2nr('-')} = "<% 
 %>"

现在当你按下 <c-s>= 时,它会插入 <%= |%> 随心所欲.

Now when you press <c-s>= it will insert <%= | %> just as you wanted.

您可能还想查看 Tim Pope 的 ragtag 插件,其中已经包含此类映射.

You may also want to look at Tim Pope's ragtag plugin which has such mappings already included.

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

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