环绕着引号 [英] Surround with quotation marks

查看:197
本文介绍了环绕着引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在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)

这篇关于环绕着引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆