New Enhancements to Rational Developer 6 Java Editor Click here to see all the Developer/Admin Tips

Date tip published:06/06/2005
Description:Rational Application Developer 6 (the replacement for WebSphere Studio 5) has added some nice enhancements in the Java editor to control comments and line indentations. This tip will highlight these time-saving additions to make your Java programming more productive!


To learn more about using Rational Application Developer 6 use the following links:

Introduction to WebSphere Using Rational Developer 6
Introduction to WebSphere for Domino Developers using Rational Developer 6




New Enhancements to Rational Application Developer 6 Java Editor


Rational Application Developer 6 (the replacement for WebSphere Studio 5) has added some nice enhancements in the Java editor to control comments and line indentations. This tip will highlight these time-saving additions to make your Java programming more productive!



Automatically Correct Line Indentation

The line indentation can be automatically adjusted. This can be done for a single line or a block of lines can be highlighted and corrected all at once.

In the following image, the readability of the Java code in the try block would be improved by adding line indentation:




To indent a block of code, first select the lines to be indented.




Then do one of the following:

    • Choose Source | Correct Indentation from the menu
    • Right mouse click in the selected code block and choose Source | Correct Indentation from the context menu
    • Press <CTRL><I> on the keyboard

The corrected indentation will be automatically applied:








Adding and Removing a Comment


To add a comment, first position the cursor on the line where the comment will be added.




Then do one of the following:

    • Choose Source | Toggle Comment from the menu
    • Right mouse click the line for the comment and choose Source | Toggle Comment from the context menu
    • Press <CTRL></> on the keyboard


Note that this command is a toggle. It will alternate between adding a comment and removing the comment. Any text on that line will be kept intact (and either made into a comment or converted back to actual code.)





Adding a Block Comment

To add a block comment, enter and then select the text for the block comment.



Then do one of the following:

    • Choose Source | Add Block Comment from the menu
    • Right mouse click in the selection and choose Source | Add Block Comment from the context menu
    • Press <CTRL><SHIFT></> on the keyboard








Removing a Block Comment

To remove a block comment, first position the input cursor anywhere in the block comment.



Then do one of the following:

    • Choose Source | Remove Block Comment from the menu
    • Right mouse click in the selection and choose Source | Remove Block Comment from the context menu
    • Press <CTRL><SHIFT><\> on the keyboard



This is an excellent way to comment out several lines of code for testing or debugging.