Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I replace a newline in Atom?

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?

like image 390
djsadinoff Avatar asked Jul 14 '15 07:07

djsadinoff


People also ask

How do you replace a line in nothing?

In the file menu, click Search and then Replace. In the Replace box, in the Find what section, type ^\r\n (five characters: caret, backslash 'r', and backslash 'n'). Leave the Replace with section blank unless you want to replace a blank line with other text.


Video Answer


1 Answers

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.
like image 68
djsadinoff Avatar answered Oct 19 '22 05:10

djsadinoff