Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make Eclipse wrap selected text in brackets

Tags:

java

eclipse

I'm using Eclipse Kepler.

It takes too long to go from the start of the block of the code to the end so I can add opening and closing brackets. I'm using Ctrl+Shift and the arrow keys to select my blocks, but I don't have a hotkey or anything to wrap the selection with brackets. I'd love to have some command such as Ctrl+Shift+( or Ctrl+Shift+9 to do this, but I can't find the way to make them.

Templates can't help me here. Preferences > General > Keys can't bind anything in the editor. Yes, I know about the Home and End buttons; this question is not about them.

I made a template:

(${word_selection})${cursor} 

This helps a bit. However, I have to use Ctrl+Space, then Up Arrow, then Enter, to use. It also only works for parentheses; if I wanted to try with, say, angle braces, it wouldn't work.

As far as I see, there is no way to bind this template with a shortcut, except making a plugin for eclipse.

like image 418
Goo Avatar asked Nov 23 '22 00:11

Goo


1 Answers

Using ${line_selection} I've made a template just like yours, and it works:

{
    ${line_selection}${cursor}
}

Also, I tried using <> instead of {} and it works.

like image 70
Rafael Avatar answered Mar 29 '23 05:03

Rafael