View files contain markup and islands of Ruby code. Any text in view files will be perceived as Ruby code in the following cases:
- In *.html.erb files, if such text is surrounded with <% and %> characters.
- In *.html.haml files, if such text follows the equals sign. Besides that, Ruby strings are correctly interpreted if preceded with ==.
Thus, having inserted the enclosing characters in view, you can type Ruby code, enjoying the Ruby-aware syntax and error highlighting and all sorts of coding assistance:
- Type the opening angle bracket <,
press Ctrl+SpaceCtrl+SpaceCtrl+SpaceCtrl+SpaceAlt+SlashCtrl+SpaceCtrl+Space or Ctrl+Back SlashCtrl+SpaceCtrl+SpaceControl SpaceControl SpaceControl SpaceControl Space, Alt Escape or Shift Space, and select % from the
RubyMine automatically completes the closing characters. So doing, the caret rests in the next editing position within the <% and %> characters.
- Press Ctrl+Shift+PeriodCtrl+Shift+PeriodCtrl+Shift+PeriodCtrl+Shift+PeriodCtrl+Shift+PeriodCtrl+Shift+PeriodCtrl+Shift+PeriodCtrl+Shift+PeriodShift+⌘+PeriodShift ⌘ PeriodShift ⌘ PeriodShift ⌘ PeriodShift ⌘ Period to insert both opening and closing characters.
- Apply one of the surround templates, using Ctrl+Alt+TCtrl+Alt+TCtrl+Alt+TCtrl+Alt+TCtrl+Alt+TCtrl+Alt+TCtrl+Alt+TShift+Alt+Z or Ctrl+Alt+TAlt+⌘+TAlt ⌘ TAlt ⌘ TAlt ⌘ ZAlt ⌘ T: