In vim
editor, I want to replace a newline character (\n
) with two new line characters (\n\n
) using vim
command mode.
Input file content:
This is my first line.
This is second line.
- Command that I tried:
But it replaces the string with unwanted characters as:%s/\n/\n\n/g
This is my first line.^@^@This is second line.^@^@
- Then I tried the following command
It is working properly.:%s/\n/\r\r/g
Can you explain why it is working fine with second command?
/
as the separator. This is more readable::%s;\n;\n\n;g
– DJMcMayhem Dec 05 '15 at 04:02\n
, replace with\r\r
,:% s/\n/\r\r/g
: https://stackoverflow.com/a/71334/911945 – Anton Tarasenko Dec 07 '18 at 15:36