Match and replace line breaks in vim
Published on
There are 2 different special characters when dealing with line breaks:
\nrepresents the new line character byte0x0a\rrepresents the carriage return byte0x0d
But in vim at the replacement side of the pattern things change a bit:
\nbecomes the null character0x00\rbecomes the new line character0x0a
So at the search side you should use \n while at replace \r.
Example:
%s/\n/\r/g

This work is licensed under a Creative Commons Attribuition-ShareAlike 4.0 International License .
