[英]Indenting of ERB tags in Vim
I recently switched over to Vim and after the initial hurdle I really like it. 我最近切换到了Vim,在经历了最初的障碍之后,我真的很喜欢它。 The only thing that might be a deal killer for me is the auto indents for erb tags being all messed up.
对我而言,唯一可能成为交易杀手的是erb标签的自动缩进被弄乱了。 I'm using the Janus plugin package which includes ruby.vim and rails.vim.
我正在使用Janus插件包,其中包括ruby.vim和rails.vim。 I also added the html5.vim because someone told me it could help with that.
我还添加了html5.vim,因为有人告诉我它可能对此有所帮助。
Here's and example of the messed up indents it does: 这是它做的缩进的例子:
<% unless @zipcode.latitude.blank? %>
<p>
<b>Latitude:</b>
<%= @zipcode.latitude %>
</p>
<% end %>
<p>
<b>Longitude:</b>
<%= @zipcode.longitude %>
</p>
Any suggestions at all would be much appreciated. 任何建议都将不胜感激。 It seems like there has to be a way to make a powerful editor like vim indent right.
似乎必须要有一种使像vim这样的功能强大的编辑器缩进正确的方法。 I'd hate to go back to sublime or aptana but this is a feature I really don't want to live without.
我不愿回到崇高的状态或aptana,但这是我真的不想没有的功能。
I believe that there are 2 possible ways of solving your problem. 我相信有2种可能的方法可以解决您的问题。
Firstly, temporarily remove the Janus distribution and replace it with a minimum .vimrc . 首先,暂时删除Janus发行版,并用最小的.vimrc代替。 Then install the ERuby plugin and see if it works.
然后安装ERuby插件 ,看看它是否有效。 If it works now then the problem has to be a conflict with one of the other plugins, and you should try reenabling the different Janus plugins one by one to see where the fault lies.
如果现在可以正常工作,则问题必须与其他插件之一冲突,并且您应该尝试重新启用不同的Janus插件,以查看问题所在。 However, if it still doesn't work then you know that the plugin itself doesn't work on your system and you could send a detailed bug report to the author (including the operating system you are using and your vim version).
但是,如果仍然无法正常运行,则说明插件本身在您的系统上不起作用,您可以向作者发送详细的错误报告(包括所使用的操作系统和vim版本)。
Alternatively, it is very easy to reconfigure Vim to use a different indentation method. 另外,很容易将Vim重新配置为使用其他缩进方法。 You could use a different built-in indentation (
:h indentexpr
), for example for XML: 您可以使用其他内置缩进(
:h indentexpr
),例如用于XML:
autocmd FileType eruby setl indentexpr=XmlIndentGet(v:lnum,1)
Or you could configure Vim to use an external indentation program ( :h equalprg
). 或者,您可以将Vim配置为使用外部缩进程序(
:h equalprg
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.