Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find and replace with newlines and carriage returns in Visual Studio Code

Task

To replace characters by carriage returns \r.
More specifically, I want to globally replace \r\n\r\n\r\n by \r\n\r\n

What I've done

  • I know how to spot newline and carriage returns in VSC. enter image description here This also allows replacement by \n, but not by\r (being filled in literally). enter image description here
  • It also doesn't help to escape the baskslash in (\\r)

Any ideas?

like image 585
Casper Dijkstra Avatar asked Oct 28 '25 14:10

Casper Dijkstra


1 Answers

It is unclear what exactly you are trying to do. But if you are just trying to reduce 3 consecutive linebreaks to 2 try:

Find: (\r?\n\r?\n)\r?\n

Replace: $1

works for me. There is no literal \r inserted - perhaps because the replacement is with a capture group.

like image 165
Mark Avatar answered Oct 30 '25 14:10

Mark



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!