在 Eclipse 中,当我选择部分文本并按任意键时,整个选择被替换。 我想知道如何制作它,而不是替换文本,而是将按下的键添加到选择的两端,就像在 visual studio 代码中发生的那样。
例子:
System.out.println(HelloWorld);
选择 Hello World
System.out.println(
HelloWorld);
然后按"按钮。代码将变为
System.out.println(");
我可以配置 IDE 以便它改为将其更改为
System.out.println("HelloWorld");
有一个像这样的问题已经回答了,但是考虑到这个问题已经有 7 年了,而且版本很旧,而且考虑到那个问题的答案是一种解决方法,我想知道是否有使它更好地工作的任何新插件或配置
最佳答案
据我所知,你想要做类似 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!
您可以将此方法用于其他事情,例如 (${word_selection})${cursor}
用于括号或 '${word_selection}'${cursor}
用于单引号。
关于java - Eclipse - 包含选择而不是替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51991652/