Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!julius.cs.uiuc.edu!apple!vsi1!wyse!bob From: bob@wyse.wyse.com (Bob McGowen x4312 dept208) Newsgroups: comp.unix.shell Subject: Re: changing a ! to a \nC where \n is a newline Keywords: vi Message-ID: <2961@wyse.wyse.com> Date: 20 Sep 90 01:23:06 GMT References: <5015@alpha.cam.nist.gov> Sender: news@wyse.wyse.com Reply-To: bob@wyse.UUCP (Bob McGowen x4312 dept208) Organization: Wyse Technology Lines: 44 In article <5015@alpha.cam.nist.gov> coleman@cam.nist.gov (Sean Sheridan Coleman X5672) writes: >I am trying to use the global substitution power in vi to >replace every occurrence of ! with a newline and a C (\nC) > >I have tried the following things: > >g/;/s//\\nC/g places the string \\nC where the ; is not a >newline. > >g/;/s//\nC/g -- places a nC where the ; is. > >Do you know how to make get vi to put a newline not a \n >when doing the substitution? You need to go into the full ex mode first by typing an upper case Q. Then you would enter: g/;/s//\ C/g The backslash at the end of the first line escapes the newline immediately after so the pattern becomes what you want. > >How about the reverse, replace a newline with a character? > To globally do this is not something I know how to do. To do it once or twice, from the visual mode type J which joins the current line and the line following into one (this replaces the newline with a space). Then you could replace the space with the character you want. Not too elegent but it works. If you have to do it often look up :map for creating a single key command out of the sequence. > >Sean Coleman >NIST >coleman@bldrdoc.gov Bob McGowan (standard disclaimer, these are my own ...) Product Support, Wyse Technology, San Jose, CA ..!uunet!wyse!bob bob@wyse.com