# Source actions

Source menu commands:

Name | Function | Keyboard Shortcut
Toggle Comment | Comments or uncomments all lines containing the current selection. | Ctrl + Shift + C
Add Block Comment | Adds a block comment around all lines containing the current selection. | Ctrl + Shift + /
Remove Block Comment | Removes a block comment from all lines containing the current selection. | Ctrl + Shift + \
Shift Right | Increments the level of indentation of the currently select lines. Only activated when the selection covers multiple lines or a single whole line. |
Shift Left | Decrements the level of indentation of the currently select lines. Only activated when the selection covers multiple lines or a single whole line. |
Format | Uses the code formatter to format the current text selection. The formatting options are configured on the Code Formatter preference page (Window > Preferences > Java > Code Style > Formatter) | Ctrl + Shift + F
Format Element | Uses the code formatter to format the Java element comprising the current text selection. The Format Element action works on method and type level. The formatting options are configured on the Code Formatter preference page (Window > Preferences > Java > Code Style > Formatter) |
Correct Indentation | Corrects the indentation of the line denoted by the current text selection. | Ctrl + I
Sort Members | Sorts the members of a type according to the sorting order specified in (Window > Preferences > Java > Appearance > Members Sort Order) |
Organize Imports | Organizes the import declarations in the compilation unit currently open or selected. Unnecessary import declarations are removed, and required import declarations are ordered as specified in the Organize Imports preference page (Window > Preferences > Java > Organize Imports). Organize imports can be executed on incomplete source and will prompt you when a referenced type name can not be mapped uniquely to a type in the current project. You can also organize multiple compilation units by invoking the action on a package or selecting a set of compilation units. | Ctrl + Shift + O
Add Import | Creates an import declaration for a type reference currently selected. If the type reference if qualified, the qualification will be removed if possible. If the referenced type name can not be mapped uniquely to a type of the current project you will be prompted to specify the correct type. Add Import tries to follow the import order as specified in the Organize Import preference page | Ctrl + Shift + M
Override/Implement Methods | Opens the Override Method dialog that allows you to override or implement a method in the current type. Available on types or on a text selection inside a type. |
Generate Getter and Setter | Opens the Generate Getters and Setters dialog that allows you to create Getters and Setters for fields in the current type. Available on fields and types or on a text selection inside a type. |
Generate Delegate Methods | Opens the Generate Delegate Methods dialog that allows you to create method delegates for fields in the current type. Available on fields. |
Generate Constructor using Fields | Adds constructors which initialize fields for the currently selected types. Available on types, fields or on a text selection inside a type. |
Add Constructor from Superclass | Adds constructors as defined in the super class for the currently selected types. Available on types or on a text selection inside a type. |
Add Comment | Adds constructors as defined in the super class for the currently selected types. Available on types or on a text selection inside a type. | Alt + Shift + J
Surround with try/catch | For the selected statements all exception that have to be caught are evaluated. A try catch block is created around these expressions. You can use Expand Selection to from the Edit menu to get a valid selection range. |
Externalize Strings | Opens the Externalize strings wizard. This wizards allows you to replace all strings in the code by statements accessing a property file. |
Find Strings to Externalize | Shows a dialog presenting a summary of number of strings not externalized. Available on projects, source folders and packages. |

Java editor
String externalization
Java development tools (JDT)

Using the Java editor
Externalizing Strings

Java editor
Java editor preferences
Java outline
Views and editors