Saturday, September 12, 2009

Some useful vi / vim tips

To replace ^M with a new line in vi, do the following.
:%s/^M/\r/g

where ^M is CTRL-V then CTRL-M
(The CTRL-V preface tells vi to use the next keystroke instead of taking it as a command.)


":set nowrap" to have no wrapping, ie. long lines will all be inside a single line. I was trying to remember this command for about 15 minutes just now.



-도시