Aurélien Gâteau

Strange first post

written on Friday, June 29, 2007

I thought I would try to write something special for my first post since I moved from kdedevelopers.org, but I just stumbled upon a nice vim trick I want to remember. Hopefully you will like it too.

Search and replace is easy in vim, it's done this way:

:%s/from/to/

What I ignored for a long time was how to insert new lines in the to field. Now I know. You need to use \r, like this:

:%s/from/one line\ranother line/

Great, isn't it?

This post was tagged tips and vim