Posts Tagged ‘editing’

What’s mining: SASS support

Tuesday, August 18th, 2009

Hello everyone,

Our team is glad to announce that development builds of RubyMine already support SASS! The feature will be available in the next public EAP build.

We originally planned SASS support for RubyMine version 2.0, but we received a lot of requests on our forums, mailing lists, in JIRA, and we changed the priorities. (So, if you miss a feature, you can have it)

For now RubyMine’s SASS support includes:

  • Syntax highlighting
  • Smart code folding based on indentation
  • Comment/uncomment actions
  • Dedicated colors page to customize default highlighting attributes
  • Smart color-editor with gutters (see screenshot)

Here you can see SASS editor with smart code folding based on indentation. The syntax highlighting attributes can be configured in File | Settings | Editor | Colors & Fonts | SASS.

SASS editor with code folding

You can see color boxes on the gutters — these are exactly the colors used within your SASS file.
You can modify them either by editing plain SASS code or using RubyMine’s Color Edtor — just click the corresponding gutter!

Smart editor for SASS color attributes

And this is not all, we have a lot of plans for future SASS codeinsight aware support like:

  • Attributes validations
  • Navigation to constant definition, parent attributes
  • and much more

You are welcome to try all these things in coming RubyMine 1.5 EAP build!

Develop with SASS! Develop with pleasure!
- JetBrains RubyMine Team

5 keyboard shortcuts to get familiar with

Monday, August 3rd, 2009

You probably know RubyMine bases on IntelliJ platform and gets lots of cool features from the platform. Going even further, I will base this post on a post in IntelliJ IDEA blog. The author of the original posting has permitted it.

We truly believe in the power of keyboard shortcuts, but some of them may be overlooked. Here are 5 combinations we advice you to try and get familiar with.

Ctrl+W & Ctrl+Shift+W: When it comes to precisely selecting a value, expression, statement or any other block of code, these shortcuts are a real killer. Just try it to see how quicker it works than the traditional Ctrl+Shift+NavKeys combo.

⌥F11/Ctrl+Shift+F12: This hides everything but the editor and so leaves you tête à tête with the code.

⌃⌥⇧Up/Down/Ctrl+Alt+Shift+Up/Down: If you are using Version Control integration, you gonna love this one — it quickly navigates you between changes in a file.

⌥F1/Alt+F1: This simple hotkey summons ‘Select target’ list allowing you instantly select the currently edited file in one of IDE views such as Project view, Changes view, etc. Comes quite useful especially on big projects and keeps you hands on the keyboard.


Ctrl+Tab, Delete: Pressing Delete while the Switcher is open (Ctrl+Tab) allows closing editor tabs and hiding tool windows
NOTE: This one only works in RubyMine 1.5 EAP since build 1287.

What’s mining: unused local variable or parameter inspection

Wednesday, June 24th, 2009

Hello everyone,

RubyMine already has a bunch of inspections that help you on the fly to write correct and clean ruby code. They are Ruby code style, Unreachable code, Unresolved Ruby reference etc. Recently we’ve added one more useful inspection: Unused local variable.

Here is a screenshot:

This inspection will warn you about local variables or parameters which values are not used in the scope. Local variable on lines 2 and 5 are highlighted with warning because values assigned aren’t used anywhere, but local variable on line 7 isn’t because you can see read access to it’s value on line 8.

If you find some errors in its behavior or have suggestions you are welcome to file a bug or post your code on the forum. Thanks for all your reports so far! Your help is invaluable in making RubyMine the smartest Ruby IDE.

Note: You can also disable this inspection from right-click context menu or in File | Settings | Inspections | Ruby.

-JetBrains RubyMine Team

What’s mining: surround selected text

Wednesday, March 18th, 2009

One small but handy thing that you’ve been asking for is the ability to quickly surround the selected text with quotes, single quotes, parentheses, etc. with a single key.

We just did it for quotes! And will also add parentheses before the next EAP build, later this week. More will come later.

Apart from that it should be mentioned that RubyMine has nice “Surround With” feature that allows surrounding pieces of code with other, more complex constructs. Try it: Ctrl+Alt+T / ⌥⌘T

We are listening carefully. So, if you want something, let us know. Here is how you can do it.

What’s mining: Extract Method Refactoring

Thursday, January 29th, 2009

We thought of making it “What’s cooking:…” but then realized we are not about food, we are about RubyMine, so — meet the new “What’s mining” blogpost series!

One of the things that’s in the works right now is the extract method refactoring. This feature is likely to appear in one of the next EAP releases.

On our developers’ machines, RubyMine can already do a simple, yet probably the most often used, kind of method extraction. Here is an example.

We have these three lines of code:

If we select the code to extract and choose Refactor|Extract Method… (or press Ctrl+Alt+M / ⌥⌘M), we can set the new method name and define parameter names and order in the following dialog:

After we click OK, the code looks like this:

Pretty simple, huh? Right, but not just simple :)

It is also smart enough to not let you easily break you code. Here is another example where RubyMine warns you about inability to make the refactoring and gives the reason.

Isn’t it cool? It is coming soon.

The following refactorings are already available in RubyMine:

  • Rename
  • Introduce Variable
  • Copy and Move for files

There are some improvements we have in mind (see the Issue Tracker) for the existing refactorings, and we also plan to add Extract Constant before RubyMine 1.0 is released.

Do you have an idea you’d like to share? Please leave a comment or start a discussion on our forum

RubyMine Rails-specific Code Completion

Wednesday, November 26th, 2008

And finally, the Rails! Rails is probably why most of us is using Ruby, right? So, RubyMine helps coding when Ruby on Rails is used.

Ruby on Rails Smartness #1

When a variable holds a model object RubyMine knows its type, its details and wisely offers the code completion.

And once you select first attribute to find_by you can try once again and RubyMine suggests again to create a complex find statement.

Ruby on Rails Smartness #2

Many Rails methods expect parameters of a certain kind or format. One example of such methods is validation methods (validate_uniqueness_of, validates_numericality_of, etc.).

RubyMine knows what should be in completion list after such methods, finds and suggests appropriate names.

Ruby on Rails Smartness #3

Quite often methods take hashes as parameters with only certain key values, ignoring the others.


class AdminController < ApplicationController

  def logout
    session[:user_id] = nil
    flash[:notice] = "Logged out"
    render :action => :index, :partial => 'bye'
  end

  def index

  end

end

Some parameters of render hash in a controller are :partial, :action, :layout and :template.

When these are used the right part of the hash is clear.

For :partial it is partial view,

For :action — the action from the controller or its parent.

For other supported parameters check the documentation.

More Types Intelligence in RubyMine

Tuesday, November 11th, 2008

In the previous article covering type inference we’ve reviewed the following cases:

  • Type Inference for local variables
  • Detecting for index variable type
  • Understanding true, false and nil

But there’s more, much more…
Let’s see more intelligence RubyMine shows when editing Ruby code.

Unknown Method Calls

If in your code you make a method call or reference an attribute that RubyMine for some reason cannot resolve, you will be notified about it by the appropriate inspection but only once for this particular method and current variable. And your code will not look all red.

If you press Ctrl+B/⌘ B on such method call it will resolve to the first occurrence where inspection error is shown.

Custom Error Types

RubyMine correctly resolves your custom exceptions and their methods when you want to handle errors in your code.


class MyError < RuntimeError # custom class representing an error
  def foo
    #foo body
  end
end

begin
  # do_something
  rescue MyError => err
    err.foo
end

Code completion shows the methods and attributes of custom error class MyError.

(more…)

Type Inference in RubyMine

Friday, November 7th, 2008

What is the one thing that some of us like and others dislike about dynamic languages such as Ruby? It is dynamic types of course! It is a blessing and a curse. And for an IDE that claims being a Ruby IDE it is a serious task. There is a lot an IDE can help developer when working with such extremely flexible type system as Ruby’s.

We think RubyMine is the leader here. And here is why.

Local Variables Type


if some_cond
  aaa = "string"
else
  aaa = [1, 2, 3]
end

aaa.          #at this point aaa is either string or array

RubyMine knows that aaa can be one of two types, so pressing Ctrl+Space for code completion shows the list of methods corresponding to possible types.


The “…” on the right means there are more than one variations.

To see the inferred types that RubyMine sees for the variable press Ctrl+Q/^ J for Quick documentation lookup.

If we choose include?(obj) and then press Ctrl+B/⌘ B for method definition, RubyMine will confirm whether to go to array.rb or to string.rb.

(more…)