How do I replace a newline in Atom?

djsadinoff picture djsadinoff · Jul 14, 2015 · Viewed 55.6k times · Source

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.

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

Answer

djsadinoff picture djsadinoff · Jul 14, 2015

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

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

  • 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.