From owner-freebsd-hackers@FreeBSD.ORG Fri Feb 8 11:33:31 2008 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5B95116A41A for ; Fri, 8 Feb 2008 11:33:31 +0000 (UTC) (envelope-from rea-fbsd@codelabs.ru) Received: from 0.mx.codelabs.ru (0.mx.codelabs.ru [144.206.177.45]) by mx1.freebsd.org (Postfix) with ESMTP id F211613C469 for ; Fri, 8 Feb 2008 11:33:30 +0000 (UTC) (envelope-from rea-fbsd@codelabs.ru) DomainKey-Signature: a=rsa-sha1; q=dns; c=simple; s=one; d=codelabs.ru; h=Received:Date:From:To:Cc:Message-ID:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:Sender:X-Spam-Status:Subject; b=L6DgCcA3+YO4d9THAnI391jGS88PsxXcgTes7QM2m8yj6+Kky6CtfOd3/nq9kQzYgB6vOslOWQpu/ud49t2pqoMK860/sKCA2Eq4HHxrXnPzxnl3uPEUc2c6OSU0/wMs6B0ARp84lVhUFtGLOGDKLUExZ4aOaTqzz1qYQPxwVBo=; Received: from void.codelabs.ru (void.codelabs.ru [144.206.177.25]) by 0.mx.codelabs.ru with esmtpsa (TLSv1:AES256-SHA:256) id 1JNRH8-000H8A-DU; Fri, 08 Feb 2008 14:20:10 +0300 Date: Fri, 8 Feb 2008 14:20:09 +0300 From: Eygene Ryabinkin To: Dag-Erling Sm??rgrav Message-ID: References: <86prv7agit.fsf@ds4.des.no> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <86prv7agit.fsf@ds4.des.no> Sender: rea-fbsd@codelabs.ru X-Spam-Status: No, score=-1.8 required=4.0 tests=ALL_TRUSTED,AWL,BAYES_50 Cc: hackers@freebsd.org Subject: Re: nvi strangeness X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Feb 2008 11:33:31 -0000 Dag-Erling, good day. Speaking for the system's nvi (not the ports one -- not using it). Fri, Feb 08, 2008 at 11:28:42AM +0100, Dag-Erling Sm??rgrav wrote: > As everybody knows, the ex/vi command for regexp substitution is > > [range] s[ubstitute] [/pattern/replace/] [options] [count] [flags] > > The man page does not document the syntax for ranges (nor for offsets or > counts for that matter) > > Assuming the syntax is the same as for ed / sed, the following should > replace every occurrence of the word wait with the word delta: > > :,s/\/delta/g > > where "," means "the entire file" Nope, "," means "from the current line to the current line". So :,s/anything/the other thing/g is equal to plain :s/anything/the other thing/g > That doesn't work, however, and neither does "1,"; only "X,Y" works, so > if you want to substitute in the entire file, you first have to find out > how long it is, then manually type in that number. > > ...or you could use the following (courtesy of roberto@): > > :%s/\/delta/g :1,$s/anything/the other thing/ will be the same as the ':%s...'. But ':%s...' is shorter to type ;)) Moreover, "1," will select lines from the first one to the current one. And, for example, ",+3" will select four lines, counting from the current and going down; "-2," will select three lines, counting from the current and going up. > None of this is documented anywhere. $ zcat /usr/share/doc/usd/13.viref/paper.ascii.gz | less and search for the 'percent sign'. -- Eygene