Vim search and replace - add new line

Was using Vim and needed to replace text where the line started with ` - text with a newline and then ### text` in a large markdown based document I was formatting

After a few goes here’s the Vim search and replace command to add new line and replace text

vim new_ling_and_replace.vim :%s/$- /\r### /g

Justin Kelly

Justin Kelly

Web Developer, Business Analytics, Data Engineer specialising in PHP, ReactJS, Tableau, AWS RedShift and Matillion ETL

Based in Melbourne, Australia

Feel free to contact me justin@kelly.org.au or _justin_kelly

Leave a comment

Name Notify me of replies by email.