I find myself wanting to highlight a string in eclipse and double or single quoting it. I can't seem to find a shortcut for it. In textmate for example if i highlight a string and type either a ' or a " the string will be surrounded with them. The same should work with ) and } i think as well.
I've added a code template for doing it but it doesn't ever appear in the menu and there doesn't seem to be a way to create shortcuts for it either. Note that this should be entirely keyboard driven and not involve any secondary menus, that's my goal anyway.
"Strings" - A pair of double quotes ("") will be inserted when a single quotation mark (") is entered. (Parentheses) and [Square] brackets - A pair of brackets will be inserted when the opening bracket is entered.
Go to Java > Editor > Templates and add a new template, e. g. called quote
, as follows:
"${word_selection}"${cursor}
Then, in the editor, write a text you want to quote, select it, press Ctrl+Space, type quote
and hit Return. The highlighted text should be quoted now.
If you don't get template proposals when pressing Ctrl+Space, make sure you have them checked in Java > Editor > Content Assist > Advanced.
Just tried it and it works for me!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With