如何在Atom中替换换行符? [英] How do I replace a newline in Atom?

查看:560
本文介绍了如何在Atom中替换换行符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Atom中,如果我在搜索和替换工具上激活了正则表达式模式,它可以找到换行符为\n,但是当我尝试替换它们时,它们仍然存在.

In Atom, If I activate regex mode on the search-and-replace tool, it can find newlines as \n, but when I try to replace them, they're still there.

是否无法在Atom中替换跨行字符串?

Is there no way to replace a newline-spanning string in Atom?

推荐答案

看起来像Atom将换行符匹配为\r\n,但是仅用任何内容替换\n时的行为都不一致.

Looks like Atom matches newlines as \r\n but behaves inconsistently when replacing just the \n with nothing.

因此换行符似乎匹配\s+\r\n,并且只有一半"的行尾匹配\n.

So newlines seem to match \s+ and \r\n, and only "half" of the line-ending matches \n.

  • 如果将\n替换为字符串,则行尾不会发生任何变化,但会将字符串追加到下一行
  • 如果将\r替换为字符串,则什么也没有发生,但是光标会前进.
  • If you replace \n with a string, nothing happens to the line-ending, but the string is appended to the next line
  • If you replace \r with a string, nothing happens at all, but the cursor advances.

这篇关于如何在Atom中替换换行符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆