넷빈즈의 루비 단축키 :: Ruby Shortcuts in Netbeans

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 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 Command-R
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
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
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 Command-F6



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 =>
doc 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

  • There is a command for reformatting/word wrapping comments. You can go into the options dialog, locate the keymap and in the "Other" category, locate the "Reformat Paragraph" action and bind it to whatever you want. The word wrapping algorithm knows about rdoc conventions and will treat lists (bulleted, numbered, and labelled) specially, will leave preformatted content alone, etc.
  • You can also enable automatic word wrapping in comments by running the IDE with -J-Druby.autowrap.comments=true (which you can also add to your netbeans.conf or nbrubyide.conf file.
  • Pressing "#" inside a double quoted string will insert #{ } with the caret in the middle
  • Pressing "#" in a string when there is a text selection will surround the text selection with #{ }.
  • Similarly, pressing left parenthesis, left bracket, left brace, single quote or double quote when there is a text selection in Ruby code will surround the text selection with the opposite character (e.g. insert right parenthesis, right bracket, ... etc on the opposite end as well.
  • Pressing ", + or _ in a comment when there is a selected word will surround the word with the same character (useful for rdoc formatting).
2007/08/05 19:25 2007/08/05 19:25
Trackback Address:이 글에는 트랙백을 보낼 수 없습니다