Ruby Development Tools Documentation - 0.6.0

Ruby Editor

The Ruby editor provides specialized features for editing Ruby code.

Associated with the editor is a Ruby-specific Outline view, which shows the structure of the active Ruby script. It is updated as the user edits the script.

The editor includes the following features:

The most common way to invoke the Ruby editor is to open a Ruby file from the Navigator or Ruby Resource View using pop-up menus or by clicking the file (single or double-click depending on the user preferences). You can also open the editor by opening Ruby elements, such as types, methods, or fields, from other views.

Code completion

If you press Ctrl+space in the ruby editor, a list with information from the current ruby file is displayed. This information includes classes, modules, globals, methods and variables. There are also suggestions for keywords and some pre-defined globals. The keywords and globals are only shown if you have already typed at least one character. If the "token" preceding the cursor does match the beginning of any suggestions you will get no suggestions.

Code formatting

The code formatter formats either the whole file or the current selection, if there is one. In the latter case all the lines, which are covered from the selection, are formatted. The code formatter does not insert new lines but only indents existing lines.

There are two options to customize the behaviour of the formatter:

  • The number of characters per indentation level

  • The character used for indentation can either be space or tab

E.g. if you format a if/then/else block, the lines of the if and else blocks have an indentation level of 1 while the lines with keywords have an indentation level of 0. The default is to use spaces and two characters per indentation level, which indents the if and else blocks with two spaces. If you changed the second option to use tabs, the if and else blocks would be indented with two tabs.

When the second options is set to use spaces, typing a tab character in the editor inserts spaces instead of a tabs, too. The number of spaces used to replace the tab is dependent on the current cursor position. Spaces will be added to move the cursor to a "tabstop", based on the number of characters per indentation level. By configuring the tab replacing settings with the code formatter settings, the difference between rawly entered code and formatted code can be minimized.

Warning

In the current version the code formatter does not recognize regular expressions which are spread over multiple lines. That implies that these regular expressions might be indented.