Reputation: 5076
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.
Upvotes: 27
Views: 20522
Reputation: 5023
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!
Upvotes: 59