Search and replace new lines in Vim
Solution
When using the search and replace feature in Vim (:%s/search/replace/
), you must use \n
to search for new line characters and \r
to replace them with new line characters.
Example of replacing new line characters with commas:
:%s/\n/,/g
Example of replacing commas with new line characters:
:%s/,/\r/g
We transform challenges into digital experiences
Get in touch to let us know what you’re looking for. Our policy includes 14 days risk-free!
Free project consultation