问题描述
如何在Eclipse JDT中将多行选择转换为String。像以下
How is it possible in Eclipse JDT to convert a multiline selection to String. Like the following
从:
xxxx
yyyy
zzz
To:
"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\n" +
"yyyy\n" +
"zzz"
然后,您可以在\\\
到
,如果你不打算换行。
Then you could just find/replace in a selection for "\n"
to ""
, if you didn't intend the newlines.
在窗口/首选项
的 Java / Editor / Typing /
下,选中该选项。 粘贴到字符串文字时转换文本
。 ( 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
)
这篇关于环绕着引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!