简体   繁体   English

Ruby.vim缩进失败,每个..do都以包含哈希('#')的正则表达式开头

[英]Ruby.vim indent fails with each..do leading with regex containing a hash ('#')

I'm editing Ruby code in Vim. 我正在Vim中编辑Ruby代码。 There is a failure in the Ruby.vim indentation which is bugging me. Ruby.vim缩进失败,困扰着我。

Here is a block of code with correct indentation: 这是带有正确缩进的代码块:

text.scan(/#/).each do |match|
    line1
    line2
end

Here is how Ruby.vim indents the code: 这是Ruby.vim缩进代码的方式:

text.scan(/#/).each do |match|
    line1
line2
end

All lines subsequent to line2 are indented to the same level as line2. 第2行之后的所有行都缩进到与第2行相同的级别。

The issue is caused by the hash (# usually means single line comment) symbol's presence in the regex. 此问题是由正则表达式中的井号(#通常表示单行注释)引起的。

Is anyone able to fix this in Ruby.vim and post the fix here? 有人能够在Ruby.vim中修复此问题并将其发布在此处吗? The problem is still present in the latest ruby.vim source on github, as linked to by Derick below. 该问题仍然存在于github上的最新ruby.vim源码中,由下面的Derick链接。

Many thanks. 非常感谢。

You can get the most up to date version of the ruby vim files from github: 您可以从github获取ruby vim文件的最新版本:

http://github.com/vim-ruby/vim-ruby http://github.com/vim-ruby/vim-ruby

i'm not sure if this will fix your problem or not... i haven't updated my ruby vim files in some time. 我不确定这是否可以解决您的问题...一段时间以来我还没有更新我的ruby vim文件。 but at least a patch can be submitted here, if it's not fixed. 但如果未修正,至少可以在此处提交补丁。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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