Path: utzoo!utgpu!watmath!clyde!att!rutgers!mit-eddie!ll-xn!vlsi!malpass From: malpass@vlsi.ll.mit.edu (Don Malpass) Newsgroups: comp.editors Subject: Re: global bug in vi Message-ID: <229@vlsi.ll.mit.edu> Date: 2 Dec 88 20:34:26 GMT References: <1039@desert.megatest.UUCP> Reply-To: malpass@ll-vlsi.arpa.UUCP (Don Malpass) Organization: MIT Lincoln Laboratory, Lexington MA Lines: 25 In article <1039@desert.megatest.UUCP> sudweeks@megatest.UUCP (Bruce Sudweeks) writes: >I seem to have found a bug in vi. > #### replace every occurance of pattern with pattern2 until end of file #### > > :.,$g/pattern/s//pattern2/ I'm home and not near any documentation, but I think that your use of 'g' here with ".,$" is improper. Global HERE means EVERY LINE, so the range probably gets ignored. You should simply do :.,$ s/pattern/pattern2/g In this case the TRAILING 'g' says to make the substitution more than once per line if necessary, but the specified range will be honored. I think your second illustration (which I've cleverly deleted from this file before talking about it, so this may be nonsense) is correct: it will check ALL lines - not a range - for PATTERN and if it finds it will make one substitution only in such lines. I'll not suggest you RTFM, because that is precisely what's wrong with vi: reading most of its documentation is about like having root canal done - rectally. Good luck. -- Don Malpass [malpass@LL-vlsi.arpa], [malpass@gandalf.ll.mit.edu] The Malpass Principle: Given a binary choice, the statistical probability of doing the right thing is 31.7% - on good days.