NetBeans Smart Semicolon — for German Keyboards

You know it – at least when using the Eclipse Code Editor: type a semicolon while editing a string literal and the semicolon will be printed at the end of the line and your cursor is placed after the semicolon. Unfortunately this happens even then when you intend to add a semicolon to the string literal. A similar function is also included in the NetBeans Java Editor. It is implemented in a more practical way I think: Ctrl+SEMICOLON adds a semiciolon to the end of the line and Ctrl+Shift+SEMICOLON adds a semicolon to the end of the line and additionally creates a new one (in other words: adds a line break after the semicolon).

If you live in Germany, that shortcut does not work: the semicolon is on the same key as the comma and only reachable if you hold the shift key pressed! But that makes an other key combination and the result is not what you want. We need to addapt the NetBeans keymap for the java editor. The keymap is found under “Tools/Options”.

Options Dialog

After clicking the “Keymap” icon on the Options dialog, the key bindings are displayed. The “Search” textbox allows to find the needed entries “Complete Line” and “Complete Line and Create new Line” quickly. In the picture above I simply entered “com” for “complete” and the search already hit the right entry.

In the shortcut column for “Complete Line” hold the Ctrl key and type comma. The key combination “Ctrl+COMMA” is entered in the column. For “Complete Line and Create new Line” hold down the Ctrl and Alt keys and type comma. The key combination “Ctrl+Alt+COMMA” is entered in the respective lines shortcut column. Both key combinations are already reserved for other shortcuts. A warning is displayed. Ignore the warning, click “Apply” and you’re done. Surely: if you want to keep the original key bindings, you have to come up with your own!

This fixes two very welcome editor shortcuts for the german keyboard layout. Try it out!

For even more cool shortcuts and hints have a look here (blog post in german).

Leave a Reply

Your email address will not be published. Required fields are marked *