Rubymine shortcut to insert <%= %>

梦想的初衷 提交于 2019-11-29 22:55:29

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 <%= %>:

You can also use code completion:

After accepting this choice you'll get:

<%= | %>

Another option is to define a 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.

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

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.

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.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!