Tag: 代码格式化

如何在aptana 3上格式化代码?

它在首选项中显示默认代码格式设置,但我看不到格式化代码文件的任何选项。请帮助。 编辑:我可以通过选择文本和ctrl + shift + F来格式化文本。 但我想格式化整个源代码或至少一个给定的文件夹。

Emacs Ruby方法参数缩进

我想让emacs缩进ruby方法调用,如: foo( :blah => ‘bar’, :shibby => ‘baz’ ) 我能得到的最接近的是: foo( :blah => ‘bar’, :shibby => ‘baz’ ) 这是使用ruby-deep-indent-paren,ruby-deep-indent-paren-style,ruby-deep-arglist全部设置为nil。 哈希缩进我喜欢的方式…如果我可以像哈希那样使方法调用缩进,我会很高兴。 有任何想法吗?

在Vim中格式化Ruby代码

现在就转移到Vim。 在TextMate中,我可以通过按Cmd – Alt – [来格式化代码。 我如何在Vim中实现同样的目标? 请参阅以下答案以获取该命令。 我发现我在.vimrc也需要以下内容,以便Vim知道如何自动提交Ruby。 if has(“autocmd”) filetype indent on endif

Ruby缩进多行字符串

这是一个最佳实践问题。 有明显的方法可以做到这一点,其中没有一个看起来很正确。 我经常需要测试是否产生了一些多行字符串。 这通常会打破缩进,使一切看起来像一团糟: class TestHelloWorld < Test::Unit::TestCase def test_hello assert_equal <<EOS, hello_world Hello, world! World greets you EOS end end 使用<<-我可以在这里缩进doc标记,但它不会剥离heredoc中的缩进,它仍然看起来很可怕。 class TestHelloWorld < Test::Unit::TestCase def test_hello assert_equal <<-EOS, hello_world Hello, world! World greets you EOS end end 这让我缩进,但测试线的可读性受到影响。 这个gsub真的感觉gsub 。 class TestHelloWorld < Test::Unit::TestCase def test_hello assert_equal <<-EOS.gsub(/^ {6}/, ""), hello_world Hello, world! […]

纯Ruby项目的目录布局

我开始学习ruby了。 我也是一个日常的C ++开发者。 对于C ++项目,我通常使用以下dir结构 / -/bin <- built binaries -/build <- build time temporary object (eg. .obj, cmake intermediates) -/doc <- manuals and/or Doxygen docs -/src –/module-1 –/module-2 — non module specific sources, like main.cpp – IDE project files (.sln), etc. Ruby(非Rails,非Merb)的dir布局会建议保持干净,简单和可维护吗?