VIM New Line or Break Line with Reguar Expression

By | November 28, 2011

So, I’ve been scratching me head for a while to findout how I could use regular expression in vim editor to break line or create a new line with a regular expression. I had about 500 email addresses in a single line seperated by comma. I wanted one email address to be in one line.

\n doesn’t seem to work with vim regular expression. So finally I had to use the following regex to get the job done.

:%s/word /word^M/g

You can produce a '^M' by hitting Ctrl-V,Ctrl-M.

Thanks peter becker for the tip.

If you like this article, then please consider sharing it. Sharing really inspires us to do things much better!!

Leave a Reply

Your email address will not be published. Required fields are marked *