在 Eclipse 中,如何用新行替换字符?

在 Eclipse 3.3.2中,我希望用文件中的新行替换字符(比如’,’)。 为了这样做,我应该在“替换”框中写些什么?

编辑: Eclipse 3.4似乎有很多答案。 Eclipse 3.3.X 有解决方案吗?

58355 次浏览

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

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.

Check box 'Regular Expressions' and use '\n' in the 'Replace with' box

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.

Like the others said, just use regular expression, but instead of just \r, put \r\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)