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/\<wait\>/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/\<wait\>/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 _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"