Saturday, September 26, 2009

My First Hack into Netbeans

This post describes how to develop a simple macro for Netbeans to comment and uncomment the selected text. By default the purpose is done by a inbuilt template in Netbeans. To comment the selected text using this template follow :
  • Select the text to be commented.
  • Press Alt+Enter. A drop-down menu will come. Select Surround with /*$selection*/
This method becomes cumbersome when you keep adding your own Templates.(How to develop your own Template in another post :P ) NetBeans allows you to develop your own macros to perform such tasks.
  • Go to Tools -> Options.
  • In Options select the Editor -> Macros tab.
  • Now Click New. A pop-up will come. Enter the macro name Comment .
  • A new entry in the macro table is entered. Select the entry and paste the following code in the Macro Code window.
select-identifier cut-to-clipboard caret-begin-line insert-break "/*" insert-break delete-previous delete-previous paste-from-clipboard insert-break remove-line "*/" insert-break
  • Set Shortcut Alt+Q (or anything you like)
Comment macro is created. Similarly create uncomment macro. Paste following code in the Macro Code window:
select-identifier last-non-white remove-line cut-to-clipboard caret-begin-line paste-from-clipboard first-non-white remove-line remove-line
  • Set shortcut Shift+Alt+Q (or anything you like)
  • Click Ok.
Now both the macros are created. To use them Select the text from the editor and press Alt+Q to comment and press Shift+Alt+Q to uncomment the commented code. Here is the list of elementary macro functions. You can develop your own using these link.

Enjoy NetBeans :)

Wednesday, September 16, 2009

Multiuser Gtalk

You can customize Gtalk to allow multiple login from a computer.
All you have to do is to goto the installed gtalk.exe or goto Start Menu right click Gtalk -> Properties
add /nomutex to the Target.

Now restart Gtalk. You can run multiple instances now.