Aptana Studio ヘルプ > はじめに > RDT (Ruby Development Tools) > Ruby Editor

Ruby code formatting

This page gives an overview of Ruby code formatting.

Introduction

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:

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.

Related Topics