Plugin highlight: “Injector” brings single-key Ruby injections into ERB

If you use ERB for your Rails views, you should like this one.

It may not be a problem for you but I always stumble when typing <% %>, let alone <%# %>. Non-letter keys and you have to press Shift too. So, I was quite impressed when I saw this Injector plugin in our plugin repository recently.

It is pretty straightforward, a single character generates the whole closure and puts the caret inside.
‘%’ –> <% | %>
‘=’ –> <%= | %>
‘-‘ –> <% | -%>
‘#’ –> <%# | %>

And even though it sounds very simple, the author has put a good thought into his work. Here’s what plugin description says:

When character is just replaced (no other key presses are made), you can cancel replacement by pressing Backspace. Characters are not replaced if cursor is already in Ruby-code block. To enable or disable Injector you can click on injector icon in the status bar or press default shortcut Ctrl+Comma(,)

Kudos to Basil G. a.k.a. toXXIc!

To install the plugin open IDE Settings | Plugins, find the Injector plugin and choose Install.

Develop with pleasure!

This entry was posted in Feature and tagged . Bookmark the permalink.

6 Responses to Plugin highlight: “Injector” brings single-key Ruby injections into ERB

  1. collin says:

    why not just use live templates?
    seems to me that it offers the same functionality, but without
    the need for a plugin.

  2. Dmitriy Likhten says:

    This plugin kind of sucks. I replaced all it’s uses with live templates, and then some. It has MANY drawbacks, allow me to elaborate:

    1) Typing simple things like will result in <input type which is QUITE annoying. I hit this situation along with when pressing – more times than I actually used the feature. Sure you can undo but why, when the more common use for me is %- -> and I can go crazy like %=t -> etc…
    2) You can no longer type %, -, =, # into live templates with this plugin. That’s right I started copy-pasting from vim to get the characters into live templates. That is beyond awful.
    3) The to undo is stupid. It needs to be very smart about it because a VERY common case is typing class= -> class -> class [OPSE, backspace, oh wait i can’t undo that expansion anymore]

    I’d honestly remove this plugin and add a few live templates. This plugin is more harm than good.

Leave a Reply to Eugene Toporov Cancel reply

Your email address will not be published. Required fields are marked *