Intention Actions in RubyMine
RubyMine provides you with a set of intention actions that can help you to quickly fix code smells, convert statements for better code style, add strings to locale dictionaries, use language injections, and do other handy things simply by pressing Alt+Enter. Let’s review all the basic and new intention actions added in RubyMine 2018.3.
Let’s start with some basic examples:
Below is a two-line statement that uses a ternary operator. You can easily convert it to an `if…end` clause, which is considered preferable for multiline statements. Just put the caret anywhere inside the statement, and press Alt+Enter:
That’s it! Note that you can rollback this change by pressing Alt+Enter again and choosing the other opposite option.
Syntax changes in the newer Ruby versions are another reason you may need to frequently use RubyMine intentions. For instance, you can quickly replace hash rockets with colons when assigning key-value pairs in hashes, to make it look a bit more up-to-date:
Some intentions may even have nothing to do with Ruby or Rails. For example, there’s an intention that will allow you to quickly check regular expressions:
New intentions in RubyMine
Let’s now take a look at some of the fresh intentions added in RubyMine 2018.3.
First of all, we’ve added a De Morgan’s law intention, to help you improve some ugly negations:
Another new intention that allows you to extract block calls to methods:
With v2018.3, you can also quickly insert a missing `end` for classes, modules, and methods:
Finally, you can now quickly flip binary expressions:
Your RubyMine Team
Subscribe to Blog updates
RubyMine 2024.1 Early Access Program is Open!
The RubyMine 2024.1 Early Access Program has now started! In this blog post, we’ll share our plans for the upcoming release and the areas we’re currently focusing on. The first EAP build includes performance and usability improvements, bug fixes, and updates to RBS language support.Now, you c…
RubyMine: How To Accelerate Project Indexing?
Hello everyone! We're excited to share more tips and tricks to enhance your RubyMine experience. In September, our team attended the Euruko 2023 conference, where RubyMine developer Maxat Mansurov delivered a fascinating talk on project indexing. Indexing is a process that involves forming indexe…
RubyMine 2023.3 EAP Update
Hello everyone! We’re back with an update on the state of the 2023.3 Early Access Program. You can download the latest EAP build from our website, via the free Toolbox App, or by using snaps for Ubuntu. Here are the biggest highlights of this release: Performance improvements As we me…
The RubyMine 2023.3 Early Access Program Is Open!
Hello everyone, The third RubyMine Early Access Program of 2023 is underway! The key change in the first EAP build is an important indexing optimization. By refactoring our code base, we’ve doubled RubyMine’s indexing speed compared to v2023.1. This is particularly noticeable when working…