In Eclipse, how do I replace a character by a new

2019-01-31 05:08发布

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 ?

6条回答
成全新的幸福
2楼-- · 2019-01-31 05:32

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.

查看更多
对你真心纯属浪费
3楼-- · 2019-01-31 05:35

Like the others said, just use regular expression, but instead of just \r, put \r\n

查看更多
迷人小祖宗
4楼-- · 2019-01-31 05:36

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

查看更多
Animai°情兽
5楼-- · 2019-01-31 05:37

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)

查看更多
虎瘦雄心在
6楼-- · 2019-01-31 05:41

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

查看更多
\"骚年 ilove
7楼-- · 2019-01-31 05:46

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.

查看更多
登录 后发表回答