RubyMine shortcuts can make your routine tasks significantly easier and faster. In this post we’d like to go over 10 of the most common and useful shortcuts you should know and use in RubyMine on a daily basis.
Search Everywhere: Shift+Shift
Double shift is the first shortcut you should learn when you start with RubyMine. It helps a lot as it literally searches everywhere, be it files, classes, symbols, or options, and jumps to the entity you need:
Double Shift can also find other actions, show their own shortcuts, and let you run them:
Moreover, you can also find and adjust your IDE settings via “Search everywhere”:
Navigate to declaration/implementation: ⌘+Click / ⌘B or Ctrl+Click / Ctrl+B
One of the most used shortcuts, this allows you to jump to the definition of any class, method, variable, asset, or any other object. Hold Cmd/Ctrl and click on the object to jump to its definition:
If an object has multiple usages, RubyMine will display a dropdown list allowing you to navigate to any of those usages:
By the way, there’s also a special shortcut for finding all usages of an object: ⌥F7 / Alt+F7
Show intention actions: ⌥Enter or Alt+Enter
Static analysis is one of RubyMine’s most essential features. If you see highlighted/underlined code in your project, it means the IDE is suggesting a possible change. Place the caret on the highlighted code and press ⌥Enter / Alt+Enter to see the available intention actions and apply one if appropriate:
Some intentions may be annoying, excessive, or debatable. In this case you can turn a specific inspection off for a particular code line, file, or the whole project:
Run Rake tasks: ⌥R or Ctrl+Alt+R
In RubyMine you can look up your routes, run database migrations, and launch any other common or custom rake tasks with a simple shortcut ⌥R / Ctrl+Alt+R:
However, if you prefer doing it the old-school way, you can always open the embedded Terminal via ⌥F12 / Alt+F12 and run Rake tasks (or any other tasks) from there.
Run … : ⌃⌥R or Alt+Shift+F10
The best way to choose a process to launch, run the app, or edit your Run configurations is to press ⌃⌥R / Alt+Shift+F10 and open the Run popup:
Tip: Hold Shift and press Enter to debug the configuration instead of running it.
Refactor this: ⌃T / Ctrl+Alt+Shift+T
Refactorings are some a popular favorite among RubyMine users. Select a piece of code, press ⌃T / Ctrl+Alt+Shift+T to open a list of refactorings relevant to it, and choose the desired option:
VCS Operations Popup: ⌃V or Alt + BackQuote
Great VCS integration is another killer feature favored by many users across all JetBrains IDEs. Should you enter your local history, switch to a different branch, compare your version with the rep, or push/update your project, ⌃V / Alt + BackQuote is the shortcut you are looking for:
Insert ERB expression-printing tags: ⇧⌘. / Ctrl+Alt+.
This shortcut is very useful when you are working with view files. When starting an ERB expression, press ⇧⌘. / Ctrl+Alt+. RubyMine will insert expression-printing tags so that you don’t waste your time typing that out manually:
Surround with HTML tag: ⌥⌘J / Ctrl+Alt+J
To wrap text in your view files with HTML tags, select it, press ⌥⌘J / Ctrl+Alt+J, and type the desired tag. RubyMine will also provide completion for the tags:
Reformat code: ⌥⌘L / Ctrl+Alt+L
This simply reformats your code according to the Ruby code style and your current preferences (Settings / Preferences | Editor | Code style). You can either hit ⌥⌘L / Ctrl+Alt+L anywhere in the editor to reformat the whole current file, or select a specific part of code inside the file and then use the shortcut to reformat the selection only:
Finally, you can always find and assign your own shortcuts in the IDE settings (Preferences / Settings | Keymap). Searching is available both by name and key bindings:
What are your favorite and most used shortcuts? Let us know in the comments below!
Don’t forget to join our users and the team on Slack if you haven’t yet.
Your RubyMine Team