Home Download Buy Blog Forum Support

Auto switch curly brackets to do end in ruby

Auto switch curly brackets to do end in ruby

Postby mega on Mon Jan 09, 2012 7:37 am

In ruby, we use "{...}" for single-line blocks, "do end" for multi-line blocks.

Sublime's snippet is great, but only support "{...}", when i need write multi-line blocks, have to switch to "do end" by myself. What i need is select "{" or just change mouse focus left to "{" and type "do" then type "tab" trigger to change "{...}" to "do end" and remain the code between "{...}".

Another relatively function is supporting do end block snippet.

Is that possible right now or plan to add this function. It's very useful for rubyist.

Thanks for help.
mega
 
Posts: 1
Joined: Mon Jan 09, 2012 7:17 am

Re: Auto switch curly brackets to do end in ruby

Postby plzBetterRubySupport on Sat Mar 03, 2012 1:05 pm

mega wrote:Another relatively function is supporting do end block snippet.

Does this means that you want an do-end-snippet?
Why don't you create some then?
As you can read in the doc ( http://sublimetext.info/docs/en/extensi ... ppets.html ) you can click on
"Tools -> New Snippet"

write something like
Code: Select all
<snippet>
  <content><![CDATA[
do ${1:|variable|}
  ${2:foo}
end
]]></content>
  <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
  <tabTrigger>do</tabTrigger>
  <!-- Optional: Set a scope to limit where the snippet will trigger -->
  <scope>source.ruby</scope>
</snippet>

Save this in the Sublime-Folder in Packages/User/ and restart.

Edit: I just saw that you also can type dob and then [tab] ( viewtopic.php?f=3&t=1338&p=6008&hilit=ruby#p6008 ).
I would be really happy if ruby support in sublime would improve :)
plzBetterRubySupport
 
Posts: 11
Joined: Sat Mar 03, 2012 12:20 pm


Return to General Discussion

Who is online

Users browsing this forum: Exabot [Bot] and 21 guests