Eclipse - Enclose selection instead of replacing

Pedro Guilherme Bueno :

In Eclipse, when i select part of a text and press any key, the whole selection is replaced. I would like to know how to make it, instead of replacing the text, add the key pressed to both ends of the selection, as it happens on visual studio code.

Example:

System.out.println(HelloWorld);

Select Hello World

System.out.println(HelloWorld);

Then press the " button. The code will turn to

System.out.println(");

Can i config the IDE so it will instead change it to

System.out.println("HelloWorld");

There is a already answered question like this one, but considering that one as 7 years and a lot of version old, and also considering that the answer on that one is kind of a work around, i would like to know if there's any new plugin or configuration that make it work better

CodeMonkey :

From what I gather, you are wanting to do something like this?

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!

You can use this method for other things, like (${word_selection})${cursor} for parenthesis or '${word_selection}'${cursor} for single quote.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=95731&siteId=1