Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!sun-barr!olivea!mintaka!bloom-beacon!eru!kth.se!sunic!mcsun!ukc!tcdcs!dce.ie!em From: em@dce.ie (Eamonn McManus) Newsgroups: comp.editors Subject: Re: How do I do this in VI? Message-ID: Date: 16 Apr 91 16:46:47 GMT References: <1991Apr15.223037.23316@massey.ac.nz> <1991Apr15.233023.10882@convex.com> Organization: Datacode Communications Ltd, Dublin, Ireland Lines: 20 tchrist@convex.COM (Tom Christiansen) writes: >>1) Copy and paste every line in a file, for eg. >:%s/.*/&^M&/ >>2) Insert a blank line after every line. For eg >:%s/$/^M/ This isn't guaranteed to work in all versions of vi. The most portable way to do, e.g., 2) is to escape to ex (with Q) and do %s/$/\ / The idea of allowing ^M to mean newline on the RHS of a substitute was introduced, according to the comments, "to get rid of the last reason for using ex" (or words to that effect). In my view it is ill-conceived because it is counterintuitive -- you have to use \^M to substitute in a real ^M. A proper solution would have been to allow : escapes from vi to contain more than one line, so that the solution above would work from vi too. , Eamonn