问题描述
如何在 Eclipse JDT 中将多行选择转换为字符串.像下面这样
How is it possible in Eclipse JDT to convert a multiline selection to String. Like the following
来自:
xxxx
yyyy
zzz
致:
"xxxx " +
"yyyy " +
"zzz"
我尝试了以下模板
"${line_selection}${cursor}"+
但是那样我只能得到整个块,而不是单独地包围每一行.如何实现多行处理,例如注释所选块?
but that way I only get the whole block surrounded not each line separately. How can I achieve a multiline processing like commenting the selected block?
推荐答案
也许这不是你的意思,而是...
Maybe this is not what you mean but...
如果我在 Eclipse 中的一行中输入双引号,然后在其中粘贴多行选择(如您的 xyz 示例),它将像这样粘贴:
If I'm on a line in Eclipse and I enter double quotation marks, then inside that paste a multiline selection (like your xyz example) it will paste out like this:
"xxxx
" +
"yyyy
" +
"zzz"
然后你可以在 ""
到 ""
的选择中查找/替换,如果你不打算换行.
Then you could just find/replace in a selection for ""
to ""
, if you didn't intend the newlines.
我认为启用此功能的选项是在 Window/Preferences
下的 Java/Editor/Typing/
下,选中 Escape text when粘贴到字符串文字中"
.(Eclipse 3.4 Ganymede
)
I think the option to enable this is in Window/Preferences
, under Java/Editor/Typing/
, check the box next to "Escape text when pasting into a string literal"
. (Eclipse 3.4 Ganymede
)
这篇关于用引号括起来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!