Ruby Options

This document lists the various command-line options you can start NetBeans with to affect features. These are typically options we've added for experimental features, or perhaps features that we aren't sure about yet - in particular how they're going to show up in the UI. These flags control functionality that may be broken, and might change from release to release. The below is accurate as of 6.0 (after beta2, although some of the flags apply to beta2 as well.)

Camel-case navigation

By default, word-navigation (delete previous word, jump to previous word, jump to next word, etc.) will navigate by "CamelCase". For example, if you have "FooControllerTest", delete word will first remove "Test", then "Controller", then "Foo". Similarly, foo_controller_test will first remove "_test", then "_controller", then "foo".

You can turn this off by running NetBeans with this flag:


Auto-wrapping Comments

You can press Ctrl-Shift-P (Command-Shift-P on the Mac) to reformat the current RDoc comment. If you want comments to be automatically reflown as you're editing them, start NetBeans with this flag:


Auto-continuing Comments

Pressing newline -within- a comment will insert a new line as a comment. However, pressing Return at the -end- of a comment will insert a blank line. The following option will make newlines at the end of comments continue the comment (unless the comment is on a line with code, where the comment is assumed to just be a single line comment referring to something earlier on the line) :


Avoiding Parentheses

In Ruby, parentheses are optional in method calls - and usage varies. NetBeans tries to be smart and looks at the documentation for the method you're calling to see if it should use parentheses or not. For example, if you're calling the "render" method in Rails, it will skip parentheses, but if you call File.exists, it will not. If you clearly prefer to avoid parentheses even when spaces are there in the documentation, use the following option. NetBeans will check to see if the expression looks ambiguous, and will insert parens if necessary, but otherwise prefers spaces:


Don't Show Browser

As part of starting the Rails server, NetBeans also automatically starts your browser and shows the application url. If you don't want this, you can turn it off with


(This works in NetBeans 6.5 and up only)

I Feel Lucky!

When you control-click (or Command-click on OSX) on a method or class, NetBeans will jump to the declaration unless there are many possible declaration classes. This happens frequently with classes which in Ruby are "open". In these scenarios, NetBeans will pop up a dialog asking you which location to jump to (with its best guess listed first). If you want NetBeans to always just jump to this location, run with the following option:


Filtering Gems

By default, in a Rails project, NetBeans will make ALL installed gems available to your files - for code completion, go to declaration, etc. Ruby projects include all gems, except for the Rails ones (although ActiveRecord -is- included). By changing this filtering, you can remove gems that add methods to core classes like Object and Module if you don't want these methods showing up in completion in your own files.

You can tweak how gems are included or excluded yourself, through the use of regular expressions. To change it globally, for all Ruby projects (not Rails projects), as follows:


The regular expression is matched against the gem file names (e.g. activesupport-1.3.5 or foo-bar-1.2.3-ruby) and if the file is in the includegems pattern it is included, else if it is in the exclude filter, it is excluded, else it is included.

For Rails projects, use the same approach except the property names are slightly different: rails.prj.excludegems and rails.prj.includegems .

You can also set these filters on a per-project basis. Edit the nbproject/ file in your project, and add these lines:


(where again, these are regular expressions as shown above.)

Choosing Ruby Interpreter

You can obviously choose your Ruby interpreter through the UI - but if you want to invoke the IDE and force it to use a particular Ruby interpreter, use the following setting:


(Obviously, put your own path to the ruby interpreter binary above)

Enabling JRuby Fast Debugging (6.1 only)

This feature is brand new and requires very fresh JRuby and ruby-debug gem bits.


Opening a File

...and while we're on the topic of startup flags - you can open files in a running NetBeans from other terminal/console windows by running

$ netbeans --open foo.rb

This will connect to the running NetBeans, ask it to open the given file and front the IDE. (P.S. This may be broken on OSX)


The IRB Console in the Windows | Output menu is hardcoded to always run with JRuby. There are some technical reasons for this; the colorized prompt, the tab-completion etc. won't work in the current output window. However, in Rails projects, there is a "Rails Console" which runs in the output window (albeit without colorized prompts or completion). This Rails Console is using your own configured Ruby interpreter.

You can get the same behavior (a new menu item in the projects context menu for Ruby projects) which runs IRB in the plain Output window with your chosen Ruby interpreter, by starting the IDE with this flag:


Note - this doesn't change the behavior of the item in the Windows menu, it adds a new item in the projects context menu.

Rails Plugins: Including Non-Lib Dirs

When indexing your Rails projects, NetBeans only includes the lib/ portion of your Rails plugins. This works well for most plugins, but I've been told there are a couple of plugins that have other important directories, such as the RailsEngine plugin. To make NetBeans scan ALL the directories in the vendor/plugin/ directories, run with this option:


NOTE: This option was added AFTER the 6.0 code freeze so only works in current dev builds.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo