34

Is there a shortcut for inserting a <%= %> in Rubymine?

I took a look in keymap and didn't see anything.

potashin
  • 44,205
  • 11
  • 83
  • 107
Tyler DeWitt
  • 23,366
  • 38
  • 119
  • 196

4 Answers4

101

The default shortcut is Ctrl+Shift+Period on Windows and Cmd+Shift+Period on Mac. It may not work on all the keyboards, in which case you can change it in Settings (Preferences on Mac) | Keymap: Main Menu, Tools, Erb, Insert <%= %>:

keymap

You can also use code completion:

completion

After accepting this choice you'll get:

<%= | %>

Another option is to define a live template:

live template

Type re, then Tab to expand.

Finally, you can define a keyboard shortcut for any text/template using the following trick:

  1. Edit | Macros | Start Macro Recording
  2. Type re, then Tab
  3. Edit | Macros | Stop Macro Recording
  4. Save it under RubyExpression name

Now go to Keymap settings and assign a shortcut to RubyExpression under Edit, Macros.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
2

Here is the plugin to make this work very easy. link

lokeshjain2008
  • 1,879
  • 1
  • 22
  • 36
1

I'm not sure if there is a shortcut or not, but usually you can just type in the first portion, and rubymine will auto close it. You just have to hit a space after you do the opening. So doing:

<%' ' outputs=> <% /code %>
<%=' ' outputs=> <%= /code %>

And it does this for the rest of the openings.

Julian G.
  • 143
  • 10
1

I show it listed as Cmd-Shift-., but that's also mapped to folding. I remapped mine to Cmd-Shift-,.

(Plain IntelliJ; RubyMine may vary slightly.)

Dave Newton
  • 158,873
  • 26
  • 254
  • 302