Close

Home » Posts tagged 'NetBeans'

Posts Tagged ‘NetBeans’

December 30th, 2009

NetBeans 6.8 and Macros

Well, I have been playing with the new release of NetBeans and I must say, I Like It!
It has a lot of useful features that I am really enjoying and find very useful fro productive development.
2 main items being the Macro Recording and the Snippet Palette.

The macros I had a bit of difficulty finding documentation on keywords, which seems to be a common issue.
So here is what I have found out, all shortcut keywords are fair game. List_Of_Shortcuts , at least anything like this adjust-caret-top is for sure.

The keyword Action is usable, eg “caret-forward”.
So say you wanted to end a string with a shortcut to place a semi colon ; at the end of the line.
Here is the macro I use
caret-forward ";" and I set it to a shortcut of Ctrl + ;

So when you have say

echo 'This{Ctrl + ;}'

right after the s in This you hit Ctrl + ; and it will jump over the last quote mark and add a semicolon

Let’s do something a little more sophisticated like a comment block for a $variable.
Here’s your code

$my_var = '';

Now you want a decent comment block for that var, here is the Macro

"/**" insert-break "@var " word-match-next insert-break "@return " word-match-next insert-break

All you need to do is use your Set Shortcut for that Macro on the line before the variable and it will make a comment block that looks like this.

/**
 * @var $my_var
 * @return $my_var
 * 
 */
$my_var = '';

So with this Macro feature you can create all sorts of speedy shortcuts.

As for the Snippet Palette, well just highlight the code and drag & drop it in the category you want and name it. That simple.