我如何才能找到/替换所有CR/LF字符在notepad++ ?

我正在寻找一些相当于微软Word中的^p特殊字符。


当前回答

假设它有一个“正则表达式”搜索,寻找\r\n。我更喜欢\r?\n,因为一些文件不使用回车。

编辑:感谢你的反馈,无论谁投了反对票。我了解到……没有,因为你没有提供任何反馈。为什么这是错误的?

其他回答

我在查找/替换窗口中使用\r\n个正则表达式时运气不太好。

然而,这适用于notepad++ v4.1.2:

Use the "View | Show end of line" menu to enable display of end of line characters. (Carriage return line feeds should show up as a single shaded CRLF 'character'.) Select one of the CRLF 'characters' (put the cursor just in front of one, hold down the SHIFT key, and then pressing the RIGHT CURSOR key once). Copy the CRLF character to the clipboard. Make sure that you don't have the find or find/replace dialog open. Open the find/replace dialog. The 'Find what' field shows the contents of the clipboard: in this case the CRLF character - which shows up as 2 'box characters' (presumably it's an unprintable character?) Ensure that the 'Regular expression' option is OFF.

现在您应该能够根据需要进行计数、查找或替换。

要找到任何类型的换行序列,请使用以下正则表达式结构:

\R

要查找和选择连续的换行序列,在\R: \R+后添加+。

确保你打开了正则表达式模式:

它匹配:

U+000DU+000A -CRLF '序列 U+ 000a -换行,lf U+ 000b -行制表,vt U+ 000c -形式馈电,ff U+ 000d -回车,cr U+0085 -下一行,nel U+2028线分隔器 U+2029段分隔符

在替换对话框中,您要将搜索模式设置为“扩展”。正常或正则表达式模式不工作。

然后只需要找到"\r\n"(对于unix文件只需要\n,对于mac格式文件只需要\r),然后将替换值设置为你想要的任何值。

如果你需要做一个复杂的regexp替换,包括\r\n,你可以通过三步方法来解决这个限制:

将所有的\r\n替换为一个标签,例如#GO#→检查'Extended',将\r\n替换为#GO# 执行regexp,例如从html书签中删除多行ICON="*"→检查regexp,替换ICON=.[^"]+。> by > 返回\r\n→勾选“扩展”,将#GO#替换为\r\n

也许你可以使用TextFX插件

在TextFX中,点击TextFX编辑→删除空行