Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!bcm!convex!newsadm From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.editors Subject: Re: How do I do this in VI? Message-ID: <1991Apr15.233023.10882@convex.com> Date: 15 Apr 91 23:30:23 GMT References: <1991Apr15.223037.23316@massey.ac.nz> Sender: newsadm@convex.com (news access account) Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 29 Nntp-Posting-Host: pixel.convex.com From the keyboard of R.Singh@massey.ac.nz (R. Singh): :Couple of questions of commands under VI? >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/ You have to precede those control-M's with a control-V. I don't think that vi is necessarily the right tool for this. I'd use sed or awk or perl. Perl offers the advantage of in-place edits: For example, for the first case: perl -n -i.bak -e 'print "$_$_"' file1 file2 file3 ... and for the second: perl -n -i.bak -e 'print "$_\n"' file1 file2 file3 ... The old version will be stored in file.bak in case of goofs. --tom