al@mot.UUCP (Al Filipski) (09/13/85)
* In "Re: Re: Vi isn't nasty enough, so user looses lines", there is the exchange: > > > ZZ is shorthand for :wq > > :wq means write it out & quit > > ZZ is shorthand for :x<CR> > ZZ is NOT equivalent to either :wq or :x on our System V.2 vi, but differs from the latter two (which seem to be equivalent) in an insidious way. For example, for an existing file foo, vi foo <change some things> :w bar ZZ does NOT cause the changes to be written to foo. However, vi foo <change some things> :w bar :wq DOES. ZZ apparently tries to be smart and avoid unnecessary writes, but I would expect it to write the file being edited in the case above. A bug, I'd call it. -------------------------------- Alan Filipski, UNIX group, Motorola Microsystems, Tempe, AZ U.S.A {seismo|ihnp4}!ut-sally!oakhill!mot!al ucbvax!arizona!asuvax!mot!al --------------------------------
kre@munnari.OZ (Robert Elz) (09/14/85)
In article <269@mot.UUCP>, al@mot.UUCP (Al Filipski) writes: > ZZ is NOT equivalent to either :wq or :x on our System V.2 vi, > vi foo > <change some things> > :w bar > ZZ > > does NOT cause the changes to be written to foo. > > ZZ apparently tries to be smart and avoid unnecessary writes, > but I would expect it to write the file being edited in the case > above. A bug, I'd call it. Wrong. ZZ writes the file in exactly the same cases as ":q" would say "file modified and not written" and not exit. Its a shorthand for people who get tired of that message, but don't want to get into the habbit of ":wq" (or ":x") every time they want to exit (which write the file every time, changed or not). The relevant point is that ZZ will not write the file if the changes exist somewhere - they may not be in the original file that you edited if you saved them elsewhere (but when I do this, I usually (99% of cases) DON'T want the changes written back to the original file) - but they do exist somewhere (maybe /dev/null if you did a ":w /dev/null" which is a useful technique at times). This discussion started when someone reported that after a "vi -r" an immediate ZZ would lose the file (not write it). That was a bug, and is fixed in 4.3 (simply a matter of the "changed" flag not being set after a "recover" operation), ":q" would have silently exited in the same circumstances. Robert Elz seismo!munnari!kre kre%munnari.oz@seismo.css.gov
chris@umcp-cs.UUCP (Chris Torek) (09/14/85)
In article <914@munnari.OZ> kre@munnari.OZ (Robert Elz) writes: >ZZ ... [is] a shorthand for people who ... don't want to get into >the habbit of ":wq" (or ":x") every time they want to exit (which >write the file every time, changed or not). Aha! The great kre finally makes a mistake! I've been waiting for this for a long time . . . :-) ``ZZ'' is exactly equivalent to ``:x'' (in fact it puts an ``x'' command into glob and goes to doinit, which amounts to pretending the user typed ``:x''). Seriously, though, the rest of what he said is correct; ``ZZ'' is not intended to be equivalent to ``:wq''. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@maryland