在 Eclipse 中,如何用新行替换字符?
在 Eclipse 3.3.2 中,我想用文件中的新行替换字符(例如“,”)。 为了做到这一点,我应该在“替换为”框中写什么?
编辑:许多答案似乎适用于 Eclipse 3.4。 Eclipse 3.3.X 有解决方案吗?
In Eclipse 3.3.2, I would like to replace a character (say ',') by a new line in a file.
What should I write in the "Replace with" box in order to do so ?
EDIT : Many answers seems to be for Eclipse 3.4. Is there a solution for Eclipse 3.3.X ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
选中“正则表达式”复选框并在“替换为”框中使用“\R”。
这是 Eclipse 3.4 中引入的新功能,请参阅 3.4 中的新增功能
Check box 'Regular Expressions' and use '\R' in the 'Replace with' box
It's a new feature introduced with Eclipse 3.4, See What's New in 3.4
选中“正则表达式”框并在“替换为”框中使用“\n”
Check box 'Regular Expressions' and use '\n' in the 'Replace with' box
就像其他人所说的那样,只需使用正则表达式,但不要只是 \r,而是 \r\n
Like the others said, just use regular expression, but instead of just \r, put \r\n
如果在选中“正则表达式”复选框的情况下执行文件搜索,则替换全部/替换所选内容也将允许正则表达式,并将 \n 转换为文件中的换行符
if the file search is performed with Regular Expressions checkbox checked, then replace all / replace selected will also allow regular expression and will transform \n to a newline in the file(s)
我正在使用 Helios 并且它可以工作,但是我在替换时遇到了一些问题...我想在这些括号“><”之间放置一个换行符 (为了使每个新的 XML 标记转到新行)...首先,我必须在 2 个括号之间放置一个字符,例如 /r,之后我选中“正则表达式”框并将 /r 替换为 \ R,这导致了正确的换行符。 否则,替换似乎是灰色的。
I'm using Helios and it works, however I had some issues with replacement... I wanted to place a line break between any of these brackets "><" (to make each new XML tag go to a new line)... first I had to place a chacter between the 2 brackets, for instance /r, after this i checked the "regular expressions" box and replaced the /r with \R, which resulted in the correct linebreak. otherwise, the replace seemed to be greyed out.
我刚刚找到了一篇关于该内容的文章问题。 这似乎是一个错误。
有一个解决方法是在剪贴板中复制新行,然后将其粘贴到“替换”框中。
I've just found an article about that problem. It seems to be a bug.
There's a workaround which is to copy a new line in clipboard and then paste it inside the "replace" box.