RubyShortcuts

Ruby Shortcuts

Recent Changes

Keybindings

This is not a complete list of keyboard shortcuts applicable to Ruby development in NetBeans; it is instead a list of some of the most important ones. For a complete set, consult KeymapProfileFor60. A handy but perhaps not as accurate PDF table is here.

Action Shortcut Mac Shortcut
Show code completion alternatives Ctrl-Space Ctrl-Space
Show documentation for the method, class or field under the caret. (Doesn't always work given Ruby's dynamic nature.) Ctrl-Shift-Space Command-Shift-Space
Show quick and short documentation, hold Ctrl key down and hover your mouse pointer over the method Ctrl-mousepointer Command-mousepointer
Show name of current parameter (when editing an argument list for a method call). (Doesn't always work given Ruby's dynamic nature.) Ctrl-P Command-P
Select applicable quickfix (when a lightbulb is showing next to the current line) Alt-Enter Alt-Enter
Jump between a Rails action (a method in a controller file) and its corresponding view (a .rhtml or .erb file). Ctrl-Shift-A Command-Shift-A
Jump between a test file and its tested file. Ctrl-Shift-T Command-Shift-T
Select the next enclosing block (hit repeatedly to select the surrounding statement, if block, method block, class, etc.) Alt-Shift-. (dot) Ctrl-Shift-.
Opposite of Ctrl-Shift-. in that it selects progressively smaller blocks around the caret. Alt-Shift-, (comma) Ctrl-Shift-,
Rename the symbol under the caret Ctrl-R Ctrl-R for 6.5, Command-R for earlier releases
Go to the declaration of the symbol under the caret Ctrl-B Command-B
Comment or uncomment (toggle comments) for the selected lines or the line containing the caret Ctrl-/ (slash) Command-/
Reformat the code (selection or full file) Alt-Shift-F Ctrl-Shift-F
Reformat the current comment paragraph (word wrapping the text according to rdoc conventions for bulleted lists, preformatted content, etc) Ctrl-Shift-P Command-Shift-P
Indent or Outdent the selected lines Tab/Shift-Tab Tab/Shift-Tab
Go to line (by line number) Ctrl-G Ctrl-G
Toggle Breakpoint on current line Ctrl-F8 Command-F8
Hippie-expand / complete the current word by inserting the next matching word from open buffers. (Hit repeatedly to cycle through matches). Ctrl-K Command-K
Open Type (go to a class in open projects or in the Ruby libraries) Ctrl-O Command-O
Open File by name prefix (not path) Alt-Shift-O Ctrl-Shift-O
Jump to other open documents (in LIFO order). Hold control key and tap the Tab key to see the list; press Tab repeatedly to cycle. Ctrl-Tab Ctrl-Tab
Run the current file. In a Rails project, this will open up the browser on the URL relevant to the file (unless it's a rakefile or a test file.) Shift-F6 Shift-F6
Test File (runs the unit test associated with the given file, or if not found the file itself as a test) Ctrl-F6 Cmd-F6
Run the current test (the test method surrounding the editor caret Alt-Shift-F6 Option-Shift-F6
Debug the current test (the test method surrounding the editor caret Alt-Shift-F5 Option-Shift-F5
Jump to matching parenthesis / brace / bracket, or other matching symbol (such as class, def, if, end, etc.) Ctrl-[[ Command-[[
Maximize the current window (typically the editor), temporarily docking all other windows (hover over to expose), press again to un-maximize Shift-Escape Shift-Escape
Open Rails Code Generator Ctrl-Insert Command-I
Select the currently edited file in the project view Ctrl-Shift-1 Command-Shift-1
Select the currently edited file in the files view Ctrl-Shift-2 Command-Shift-2

Snippets

See the RubyCodeTemplates document for more details.

There's a large number of code templates bundled with NetBeans. The following brief list just summarizes a few you might find convenient. To use, type the abbreviation in the editor and then hit Tab. Use the Tab key or Enter to finish each "section" in the template (if there are multiple). Shift-Tab will cycle backwards. The current editing section is shown in a blue highlight.

Abbreviation Description
: Insert a hash entry of the form :key => "value"
l Insert =>
do Insert a do block with an unused block iterator variable
r In an RHTML file: Insert <% %>
re In an RHTML file, insert a Ruby Expression: <%= %>
jc For JRuby, require java and import a class by fully qualified name
ife If-else block
begin Begin-rescue-end block

Other Tips

-J-Dno-ruby-camel-case-style-navigation=true

Note that ... is a workaround for the bug where ... in an RHTML file inserts the linefeed after a %>. marker. --PhlIp

Retrieved from "http://wiki.netbeans.org/RubyShortcuts"