NetBeans: Editor tricks

I've been a NetBeans user for years now. So I don't read manuals nor documentation. I just use it and that's all. But during the last NetBeans Day in Madrid I learned lots of things about NetBeans' editor. Things I didn't know, things that I missed, things I wanted to share with you in this entry.

I must admit I type too fast, so I don't play that much attention to editor hints. While attending Gregg Sporar's presentation I learned quite a lot of little tricks.

Alt-P - method parameters in code completion

Want to show the arguments to a method call? Then press "Alt-P" while writing a method call. This shows the list of expected arguments for the method you're writing. It seems NetBeans documentation on new features contains a detailed list of this and other features.

Alt-Enter - editor hints

Have you ever seen a small lightbulb in the left margin while editing? This means that NetBeans is giving you a hint. If you press "Alt-Enter" to see the list of fixes that NetBeans is proposing you. If you choose one NetBeans writes the fix for you. Oh, my, this is cool!

Ctrl-Space - Autocomplete

Well, I already knew this one. This opens the autocomplete popup. I'm just including it for the sake of completeness ;-)

Ctrl-K and Ctrl-L

I learned this one in the NetBeans Day too. This shortcut is just fantastic! It searches upwards (Ctrl-K) or downwards (Ctrl-L) for the workds (any words) that fit your current typing. It knows nothing about syntaxis so it works everywhere in your source files (including javadoc comments). Typing Ctrl-K again shows the next match (in case there're several matches that fit your typing). Ctrl-K (and Ctrl-L) is very fast (because it doesn't do any syntax checking).

For a better explanation see Cheng's blog.

Regexps for replacing things

I didn't know this one, of course. I do miss this feature (I'm a "vi" fan), so I was certainly surprised to know that regexps can be used for replacing things.

An example in Roumen's weblog.

Code templates (editor macros)

This is cool too. The new "Tools/Options" dialog lets you write code templates. This is some sort of macros you can write yourself (quite easily) and that reduce the amount of typing. Edgar Silva's blog has a nice explanation of the this feature.

Hyperlinking your source code, that easy

Hold Ctrl and move your mouse over any editor word. Is it underlined? Then just clicking on it you can navigate directly to the source for that method/class. That easy.

Want to go back to the original source location? See that little yellow arrow in the editor bar? Then click on it and you're back into the previous source. This is my preferred way to navigate source code now!!

It seems Roumen blogged about this feature a while back (my fault not reading Roumen's blog too often :-()


I didn't know this one either. It seems you can navigate through the list of open buffers by pressing Ctrl-Tab. I cannot try this out because Ctrl-Tab is associated to a KDE operation. To enable it on my box I'll have to remove Ctrl-Tab from KDE's keyboard shortcuts.

Geertjan explains this feature in his blog

Hide a piece of code

It seems you can "hide" (collapse) a piece of code by adding comments. This is very cool if you're sharing your code with other people and you want to tell them that part should not be edited.

This (anonymous?) blog contains an example

Split editor windows

This is useful if you're trying to compare two files. It seems you can split the editor window by just dragging an editor tab over the place. This is equivalent to a :split or :vsplit in gvim.

Again Roumen's blog explains this too

What else?

So if you know about any other cool feature I'm missing I'd appreciate a link or a short explanation. I'd like to aggregate these cool features.

After all, as the Pragmatic Programmer states:

"Use a Single Editor Well - The editor should be an extension of your hand; make sure your editor is configurable, extensible, and programmable."

The Pragmatic Programmer

Happy NetBeans-ing, Antonio


In case you're wondering, well, yes: I've already done a man rtfm in my Linux box ;-)


Is it RTFM or RRGB (Read Roumen's and Geertjan's Blogs)? :-D

blog comments powered by Disqus