NetBeans Mac customization
Developer — 5 Oct 2006 05:31 — 1255 days ago

I’ve used Eclipse for my previous Java coding projects, especially for servlets, XML, graphics and web services projects, and I’ve been very happy with it.

For a new project which focuses more on client-side Swing GUI than server-side web technologies, I am using NetBeans 5.5 with its Matisse GUI builder, and after working with it for a while I am impressed by what I see.

Writing code in an editor/IDE involves many personal preferences and I got the impression that I can get NetBeans and especially its text editing keyboard shortcuts to match the Mac conventions more closely. I am totally used to BBEdit and Cocoa text view shortcuts, I use shortcuts a lot, and I find it very distracting when they are different, especially the ones for navigation and text selection.

Some issues might seem minor but they irritate me when they occur. For example there are two different actions for move to start of line and move to start of text on line in NetBeans and I can choose which one I need. I could never get Eclipse to make ⌘-⇠ move the cursor all the way to the very start of a line, including the leading whitespace in non-Java sources.

NetBeans also made other customizations easy, for example it works well with my coding font, LucasFonts TheSans Mono Condensed Five. (It doesn’t look so hot on that web page, but when rendered with Apple’s subpixel anti-aliasing it looks fantastic). To get that to work right in Eclipse I always had to disable the other fonts in the same font family because Eclipse would use a different font (in the same family) than the one I actually picked.

The Matisse GUI Editor and the GroupLayout manager really do make Swing GUI development a lot easier. It’s not Cocoa/InterfaceBuilder yet, but definitely nicer than what I used before for Java user interfaces. (BTW GlazedLists is a killer library which provides collection classes with event handling and propagation smarts. It comes rather close to Cocoa Bindings and eliminates quite a bit of controller code). I am usually wary of tools that generate source code, but Matisse implements it quite nicely, with a clean separation between system- and user-generated code. Switching back and forth between code and layout view and making changes in both never caused problems.

I use some hairy nested GUI panels and NetBeans’ navigator panel in the layout mode allowed me to look at and work on each nesting level in isolation.

Java code editing is supported very well, with lots of smart tools that boost productivity. The user interface is logical, pretty much everything is where I expect to find it. It also looks quite good, nice toolbar icon artwork, few obvious visual glitches.

The build system is Ant-based, which is what I always wanted from a Java IDE. Most of my projects are built and/or packaged with automated, command-line based processes so that is a perfect fit.

Following are some random NetBeans customization notes if you come from a Mac/BBEdit background like me.

Install the camelCase plugins by Sandip Chitale. I am hooked on camelCase navigation/selection with the ^ ⇠ / ^ ⇢ keys ever since BBEdit added them in the last version.

Here’s what I think Mac text editing keyboard shortcuts should be :-) This is a major reason why I like NetBeans so much, I was able to configure it almost perfectly to this setup. Again it might sound weird to put such an emphasis on this issue, but I switch coding environments a lot (BBEdit, Xcode, Java IDEs, Cocoa text views, AppleScript editor etc.) and differing shortcuts introduce a lot of mental friction, which is the last thing I need when writing software.

⌘ ⇡⌘ ⇣Insertion Point to Beginning/End of Document
⌘ ⇠⌘ ⇢Insertion Point to Beginning/End of Line
⌥ ⇠⌥ ⇢Insertion Point to Previous/Next Word
^ ⇠^ ⇢Previous/Next Camel Case Position
⌘ ⇧ ⇡⌘ ⇧ ⇣Extend Selection to Beginning/End of Document
⌘ ⇧ ⇠⌘ ⇧ ⇢Extend Selection to Beginning/End of Line
⌥ ⇧ ⇠⌥ ⇧ ⇢Extend Selection Back/to Next Word
^ ⇧ ⇠^ ⇧ ⇢Select to Previous/Next Camel Case Position
⌘ ⌫⌘ ⌦Cut from Insertion Point to Line Beginning/End
⌥ ⌫⌥ ⌦Delete Previous/Next Word
^ ⌫^ ⌦Delete to Previous/Next Camel Case Position
⌘ ⌥ ⌫Delete Line
^ LSelect Line
⌘ ⇧ ZRedo
⌘ BBuild
⌘ RRun
⌘ JGo to Line
⌘ ^ JGo to Javadoc (because F-keys are inconvenient on a laptop)

The only tiny difference left is that ⌥ ⇢ includes the whitespace after the word in NetBeans, but doesn’t in BBEdit/Cocoa. Also, Select Line doesn’t select the trailing line break.

Most of these actions are in the Other category, where I didn’t look for them until I read this posting.

As a Cocoa text view side note, ^-L is a special short cut which was originally inspired by BBEdit’s ⌘-L but I moved it to ^-L when I configured it in Cocoa’s text bindings to make it available in all Cocoa text views, including programs like Apple Mail. It’s configured like this in my ~/Library/KeyBindings/DefaultKeyBinding.dict:

{ "^l" = "selectLine:"; /* Ctrl-l = select line */ }

Selecting the entire current line is quite useful, I often use it followed immediately by the delete key to delete the current line.

One thing I miss is hitting ⌘-E to put the selection into the find clipboard. I often use that together with ⌘-G to immediately find the next occurrence of the string without bringing up the Find dialog. I often capture the find string in one document and switch to a different one to invoke Find Next there without ever seeing a Find dialog. I might need to write a NetBeans plugin for Use Selection for Find :-).

While I was writing this blog entry, NetBeans was updated from 5.5beta2 to 5.5RC1 and I lost all my customizations when I switched, that wasn’t so nice. So (mostly as a note to myself for next time) here’s my list of customizations for setting up a fresh copy of NetBeans:

  • Download and install the profiler
  • Add Sandip Chitale’s plugin update channel and then hit the update center to load up on his and Sun-supplied plugins
  • Prefs: Auto Update - Every Startup (because I’m an update junkie :-)
  • Prefs: Customize coding font
  • Prefs: Setup keyboard shortcuts
  • Prefs: Color > Highlighting > Selected Text -> Black Foreground, OS X selection color Background (because the default inverted white-on-gray text is really weird).
  • Reduce font size because the default is too big and clunky
  • Hide Edit, File and other unused toolbars

Code templates:

// Abbreviation if1 if (${condition}) ${cursor};
// Abbreviation if2 if (${condition}) { ${cursor}; }
Comments
Posted by Jim on 6 Nov 2006 01:22

i'm just curious if you've ever given TextMate a run for its money, and if so, what you thoughts are about it :)

personally TextMate is like my right arm, and i'm not left handed ;)

Posted by Marc on 6 Nov 2006 10:04

Yes I think TextMate is nice, I bought a license a while ago but I don’t use it right now.

Because I’ve been using BBEdit since before Mac OS X, that is what feels like my right arm and I’m totally used to it.

What I like a lot in TextMate is the Bundle / Snippet system/language, they are very powerful mechanism for extension by the user.

What I really miss right now is an organizational feature like BBEdit’s side panel that allows me to group several documents into one window, especially remote files opened via Interarchy.

Posted by Juan Rada on 22 Nov 2006 16:05

Hi!... I've been using NetBeans for Mac OS X since April and I've been trying to configure my keyboard with the same setup you showed in your table and I HAVEN'T FOUND THE WAY! I also thought of moving back to Eclipse but in the company everyone uses NetBeans. I would go to hell and back to know how can I reconfigure NetBeans keyboard Bindings to work just like all Mac Apps.

Thank you very much!

Juan R.

Posted by Marc on 22 Nov 2006 16:20

Juan: You reconfigure the shortcuts here: “NetBeans” Menu -> “Preferences” -> “Keymap”. Most of the actions are in the “Other” category so you’ll want to open that one.

Posted by Juan Rada on 22 Nov 2006 16:25

Hi again... I went to hell and back... I found those shortcuts in Other's node. This is not very intuitive. NetBeans should work on a better keyboard integration with Mac OS.

So happy I found this :)

Thanks Again

Posted by Marc on 22 Nov 2006 16:40

Didn’t you see what I wrote in the article above?

I wrote: “Most of these actions are in the Other category, where I didn’t look for them until I read this posting.”

Posted by Jim Minnihan on 8 Mar 2007 04:43

Hi Marc,

How is your performance when running NetBeans 5.5 release version on your Mac? What kind of Mac are you running it on? I am having nothing but trouble with the speed of NetBeans 5.5 on my Powerbook G4 1.33 GHz. Can you let me know what kind of Mac you run it on, and what your netbeans.conf startup looks like? Also, are you loading the Visual Web Pack extension?

Thanks for your time.

Sincerely,

Jim Minnihan

Posted by Marc on 8 Mar 2007 09:15

Jim: I am generally happy with NetBeans' performance, but I run this on a MacBook Pro with lots of RAM.

I am currently not loading the Visual Web Pack extension, but other visual tools, like UML editing, tended to be a bit slow.

This is my netbeans.conf config line:

netbeans_default_options="-J-Dfile.encoding=UTF-8 -J-Dapple.awt.graphics.UseQuartz=true -J-Xms32m -J-Xmx51
2m -J-XX:PermSize=32m -J-XX:MaxPermSize=160m -J-Xverify:none -J-Dapple.laf.useScreenMenuBar=true --fontsiz
e 11"

Powered By blojsom