Sublime Forum

Insert erb tags

#1

One very common feature of textmate that I miss is to add erb tags, and cycle them:

<%= %> using ctrl (shift) ‘>’

Is there any equivalent in sublime?

0 Likes

#2

I actually add this snippet to every editor I use. I use the NetBeans standard of “re+TAB” for <%= %> and "r+TAB for <% %>… just cause NetBeans is the editor I was using when I started doing Ruby. Get Ryan Bates’ “Ryan on Rails” bundle for some really helpful ERB stuff.

Creating snippets yourself is super easy. Take a look in your package directory for some great examples.

0 Likes

#3

Adding the following into the User sublime-keymap file adds the function to insert <%= 5> but it doesn’t toggle between <% %> unfortunately :cry: . Anybody have any ideas?

[code] { “keys”: “ctrl+shift+.”], “command”: “insert_snippet”, “args”: {“contents”: “<%= ${0:$TM_SELECTED_TEXT} %>”}, “context”:

    { "key": "selector", "operator": "equal", "operand": "text.html, source.yaml, meta.erb" }
 ]

}[/code]

0 Likes

#4

I’ve created a plugin that inserts and cycles the ERB tags. You can download it here:

github.com/eddorre/SublimeERB

0 Likes

#5

awesome, this needs to be added natively to sublime.

0 Likes