<p>Is there an Eclipse command to surround the current selection with parentheses?</p>

<p>Creating a template is a decent workaround; it doesn't work with the "Surround With" functionality, because I want to parenthesize an expression, not an entire line, and that requires <code>${word_selection}</code> rather than <code>${line_selection}</code>.</p>

<p>Is there a way that I can bind a keyboard shortcut to this particular template? <kbd>Ctrl</kbd>-<kbd>space</kbd> <kbd>Ctrl</kbd>-<kbd>space</kbd> arrow arrow arrow isn't as slick as I'd hoped for.</p>

[{'answer_id': 67031, 'author': 'DustinB', 'author_id': 7888, 'author_profile': 'https://Stackoverflow.com/users/7888', 'pm_score': 2, 'selected': False, 'text': '<p>Easy, Window->Prefs, then select Java->Editor->Templates</p>\n\n<p>Create a new template with : (${line_selection}${cursor})</p>\n\n<p>The "line_selection" means you have to select more than one line.</p>\n\n<p>You can try creating another one with "word_selection", too.</p>\n\n<p>Then, select text, right click, Surround With... and choose your new template.</p>\n'}, {'answer_id': 67098, 'author': 'Vladimir', 'author_id': 9641, 'author_profile': 'https://Stackoverflow.com/users/9641', 'pm_score': 6, 'selected': True, 'text': '<p>Maybe not the correct answer, but at least a workaround:</p>\n\n<ol>\n<li><p>define a Java template with the name "parenthesis" (or "pa") with the following :</p>\n\n<p>(${word_selection})${cursor}</p></li>\n<li><p>once the word is selected, <kbd>ctrl</kbd>-<kbd>space</kbd> + <kbd>p</kbd> + use the arrow keys to select the template</p></li>\n</ol>\n\n<p>I used this technique for boxing primary types in JDK 1.4.2 and it saves quite a lot of typing.</p>\n'}]
['https://Stackoverflow.com/questions/66986', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3474/']