A recent update to Textmate added a variable to the do
snippet. So when you type 'do' followed by a tab, you get
do |variable|
end
Most of the time I don't need a variable, so I want the default 'do' snippet to not have a variable.
Open TextMate and use the keyboard shortcut to open the Snippet editor (Ctrl+Alt+⌘) Click Ruby in the Snippets area, click the plus sign (+) in the bottom left corner and click 'New Snippet'.
Name the snippet 'Insert do … end', assign Activation (Tab Trigger) the value 'do' and Scope Selector the value 'source.ruby'. The snippet text should be
do
$0
end
Finally, change the existing Snippet named 'Insert do |variable| ... end' Activation (Tab Trigger) the value 'dov'. Now when you type 'do[tab]' you will get the 'do … end' block without a variable. When you type 'dov[tab]' you will get the 'do |variable| ... end' block.
Need web application development, maintenance for your existing app, or a third party code review?
Velocity Labs can help.
Hire us!