Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!ucbvax!TRANSARC.COM!Dan_Bloch From: Dan_Bloch@TRANSARC.COM Newsgroups: comp.editors Subject: Re: vi: search for or go to a line not of length n Message-ID: Date: 25 Sep 90 23:20:48 GMT References: Sender: daemon@ucbvax.BERKELEY.EDU Lines: 36 lee@chsun1.uchicago.edu (dwight lee) writes: > A BITNET site sent me a uuencoded binary, and it showed up in my mailbox > with blanks at the ends of lines stripped, and some lines concatenated. > I'd like to use vi to patch the file up so that it can be properly decoded. > > Most uuencoded lines are 61 characters long. I'd like to be able to > search for a line that isn't 61 characters long. Any reasonably automated > method will do! Regexps, macros... anything. Okay, here we go. What you want to do is something like :v/^..............................................$/s/.*/&/ That should be 61 dots. I put in fewer in the interest of having it all fit on one line. What this does is finds every line that isn't exactly 61 characters long and put on the end of it. Then you can search through the file for normally for , take whatever actions you want, and delete all the s when you're done. Obviously, you can use any handy marker instead of . > Also, is there a way for a search in vi to be inverted? ie "search for > the next line which does not begin with a capital M". This would also be > good for checking on mangled uuencoded files. That's what the :v command above does. It's exactly like :g, only it searches for lines not matching a given pattern. It only works as a line mode command, so if you want to treat each line individually you need some trick like tagging them. > Feel free to suggest an alternate method of repair, too. Thanks to you all! Couldn't you get the guy to retransmit it? Dan Bloch dan@transarc.com