The IDE source editor supports both shortcut keys and code templates.
The Ruby editor supports a large number of shortcut keys. The following web page lists the most useful ones:
In addition, the editor supports the standard IDE source editor shortcut keys listed in Editor Shortcuts.
The editor supports some standard Ruby and Ruby HTML (RHTML and ERB) code templates—abbreviations that expand into snippets of code when you type the snippet name in the editor and press Tab.
For example, type def
and press Tab to produce a skeleton method declaration in which you type the method name and parameters and then press Enter to put the edit cursor in the method body.
When you expand a code template, the editor enters a new state in which the areas where you type, the template parameters, are highlighted in blue, and you can press Tab or Enter to jump from one live code template parameter to the next or press Shift-Tab to go back.
For example, type :
and press Tab. You see the following template with the key
parameter highlighted in blue:
:key => "value",
If you type a key name and press Enter, the value
parameter of the template is highlighted in blue, and you can enter the value of the key-value pair. With the highlight on value
, you can press Shift-Tab to return to the key
parameter.
Code templates are assigned based on the mime type of the file you are editing. A different set of templates is used in a Ruby file than in ERB and RHTML files. A number of standard Ruby code templates are built in and can be used directly, such as a subset of the TextMate snippets. You can also define your own code templates as described in Creating and Customizing Ruby Code Templates.
The following two web pages list the available code templates: