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

时间:2023-02-05 11:59:54

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 ?

在Eclipse 3.3.2中,我想用文件中的新行替换一个字符(比如',')。我应该在“替换为”框中写什么才能这样做?

EDIT : Many answers seems to be for Eclipse 3.4. Is there a solution for Eclipse 3.3.X ?

编辑:许多答案似乎是针对Eclipse 3.4。是否有Eclipse 3.3.X的解决方案?

6 个解决方案

#1


133  

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

选中“正则表达式”复选框,然后在“替换为”框中使用“\ R”

It's a new feature introduced with Eclipse 3.4, See What's New in 3.4

这是Eclipse 3.4引入的新功能,请参阅3.4中的新功能

#2


1  

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

就像其他人说的那样,只需使用正则表达式,而不只是\ r \ n,将\ r \ n放在\ r \ n

#3


0  

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

选中“正则表达式”复选框,然后使用“替换为”框中的“\ n”

#4


0  

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.

我正在使用Helios并且它有效,但是我有一些替换问题......我想在这些括号“> <”之间放置一个换行符(以使每个新的XML标签转到一个新行)。首先我必须在2个括号之间放置一个字符,例如/ r,之后我检查了“正则表达式”框并用\ R替换了/ r,这导致了正确的换行符。否则,替换似乎是灰色的。

#5


0  

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.

有一种解决方法是在剪贴板中复制新行,然后将其粘贴到“替换”框中。

#6


0  

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)

如果选中了正则表达式执行文件搜索复选框,则替换所有/替换选中也将允许正则表达式并将\ n转换为文件中的换行符

#1


133  

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

选中“正则表达式”复选框,然后在“替换为”框中使用“\ R”

It's a new feature introduced with Eclipse 3.4, See What's New in 3.4

这是Eclipse 3.4引入的新功能,请参阅3.4中的新功能

#2


1  

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

就像其他人说的那样,只需使用正则表达式,而不只是\ r \ n,将\ r \ n放在\ r \ n

#3


0  

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

选中“正则表达式”复选框,然后使用“替换为”框中的“\ n”

#4


0  

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.

我正在使用Helios并且它有效,但是我有一些替换问题......我想在这些括号“> <”之间放置一个换行符(以使每个新的XML标签转到一个新行)。首先我必须在2个括号之间放置一个字符,例如/ r,之后我检查了“正则表达式”框并用\ R替换了/ r,这导致了正确的换行符。否则,替换似乎是灰色的。

#5


0  

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.

有一种解决方法是在剪贴板中复制新行,然后将其粘贴到“替换”框中。

#6


0  

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)

如果选中了正则表达式执行文件搜索复选框,则替换所有/替换选中也将允许正则表达式并将\ n转换为文件中的换行符