1

我正在Textmate2中开发Ruby on Rails应用程序。我必须在 Rails 编码中使用很多花括号语法。{}

默认情况下,当我输入左花括号{时,{}会自动显示。在大多数 Rails 教程中,在开始和结束位置的花括号之间放置空格是很常规的。例如,

{ name: "aaa", email: "aaa@gmail.com" } # hash example
it { should have_selector('p', 'some text') } # rspec example

在每个编码句子中手动放置空格有点累。我想自动在大括号之间放置空格。我的意思是当我输入时{,我希望{ }默认出现。

我不知道我需要修改哪些捆绑包。请告诉我如何完成这种语法。

4

1 回答 1

0

为此,您需要创建自己的代码段:

打开Bundle EditorRuby从列表中选择。按Command+n创建一个新项目,Snippet从下拉列表中选择。

将您的新名称命名Snippet为合适的名称,也许是“间隔花括号”。片段编辑器应仅包含:

{ $0 }

Bundle Editor抽屉中单​​击Key Equivalent以将代码段绑定到一个键,在这种情况下使用{

这将导致此代码段在 TextMate 中无处不在,将其限制为仅在 Ruby 中工作 更改Scope Selectorsource.ruby,或为 Ruby on Rails 人员:text.html.erb.rails, source.ruby.rails, source.ruby.rails.embedded.html, meta.rails.helper, meta.rails.unit_test, meta.rails.controller, meta.rails.functional_test, text.haml, source.ruby.rspec

于 2014-04-30T22:03:52.840 回答