Saturday, 3 December 2011

Usefull NetBeans Shortcuts


It’s been several days that I am relying solely on NetBeans for my PHP and Java coding. So far, it’s beyond my wildest expectations – I am totally satisfied with that great IDE. Today, I have searched for shortcut that would allow me to duplicate a given line, and (fortunately!) came by a great post – Top 10 NetBeans IDE Keyboard Shortcuts. Not only I found the line-duplication thing, I discovered several other pearls which due to unavailability in my previous IDEs, I even didn’t consider to look for.
So, I decided to compile my own list of shortcuts that save me a lot of time during code-sessions.
Shift + Esc Toggle Work-space Maximize/Minimize
Like the original post author, I really like to have as much work-space available for code itself as possible. And when I occasionally need to see one of the supplementary panels (like Files, Project, Navigator etc), I rely mostly on short-cuts, w/o toggling back. So, if I need to view some docking panel I hit one of the following:
Ctrl+1 – Project Window
Ctrl+2 – Files Window
Ctrl+3 – Favorite Window
Ctrl+4 – Output Window
Ctrl+5 – Services window
Ctrl+6 – Tasks Window
and when I am done, Ctrl+0 to get me back to editor. Try for yourself, I am pretty sure, you’d be amazed how much time this saves you, while making coding area less cluttered.
Alt+Enter View fix suggestions
NetBeans makes your life a lot easier, its Java code analyzer does a really solid job. Most of errors are filtered even before compilation – should you see the light bulb on the left of your code, you can review fix suggestions by either clicking on it or (time-saver again!) by just hitting Alt+Enter. I personally enjoy this one, as I prefer to see why IDE is complaining w/o releasing my hands of the keyboard.
Ctrl+F12 Navigate to Member
If your class is too big, then Members View in Navigator (Ctrl+7 remember?) might not be the best option. Just hit Ctrl+F12 and you’d be able to navigate more easily, as it has filter that would eliminate non-matching members while you are typing.
Alt+Insert Generate code
That’s one of my favorites – code generators for getters/setters/constructors are just too sexy to ignore. This shortcut makes them even more usefull.
Ctrl+Shift+ArrowDown Duplicate Line
Duplicating lines never been easier :) If you want a new duplicate to be inserted before the current line, use ArrowUp instead of ArrowDown.
Ctrl+W Close Current Window
Firefox honors this short-cut, as well as Konqueror. So, I even configured my console to use this by default. In no time you’d be accustomed to hit this combination instead of Ctrl+F4.
Ctrl+PgUp and Ctrl+PgDn Navigate through Windows (previous/next)
Again, got used to it from Firefox. Makes it a swift to loop through open documents.
Ctrl+P Display method’s arguments
Within method’s braces hit this combination to see what parameters are there. Comes where handy when reviewing the code.
Ctrl+; Add semicolon to the end of the line w/o leaving current cursor position
If you are working on some code line and NetBeans underlines it red (due to [yet] non-existent semicolon at the end of the line) hitting Ctrl + ; (Ctrl + semicolon) is enough to close the statement, while you are still positioned at the very same place on line. First saw this on dzone.com blog, and really liked using it.
Ctrl+K and Ctrl+L Auto complete with previous/next matched word
I use this combination even more often than Ctrl+Space to auto complete. Listing all items with Ctrl+Spacemight be slow, but hitting Ctrl+K is instant. More than often the variable name you are typing is already typed somewhere in the current file, thus matching it with Ctrl+K or Ctrl+L is probably most obvious thing to do.
Ctrl+E Delete current line
Ctrl+Del and Ctrl+BackSpace Delete next/previous word
I generally use Ctrl+BackSpace, but on some occasions Ctrl+Del also proved userful.
That’s more than enough to get you going. In some time, I plan to write more extensive list  of esoteric shortcuts you rarely use, because you rarely know about them.
And what shortcuts save your time?

No comments:

Post a Comment