Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!uunet!mcsun!hp4nl!sci.kun.nl!cs.kun.nl!hansm From: hansm@cs.kun.nl (Hans Mulder) Newsgroups: comp.editors Subject: :wq (Re: One user's editor wish list) Summary: Don't use :wq. Use :x. Message-ID: <2900@wn1.sci.kun.nl> Date: 27 Mar 91 16:18:34 GMT References: <1991Feb22.134323.20410@scrumpy@.bnr.ca> <1991Mar25.191821.11019@scrumpy@.bnr.ca> Sender: root@sci.kun.nl Organization: University of Nijmegen, The Netherlands Lines: 44 In article <1991Mar25.191821.11019@scrumpy@.bnr.ca> bnrmtl!lewis@larry.mcrcim.mcgill.edu (Pierre Lewis) writes: >1) vi commands :w :q and :n > > With the vi on our SunOS 4.0.3, I can do the following: > :w to write back a file > :q to quit the editor > :wq to write back a file AND quit the editor > > I can also do: > :n to move to next file (if current file has no pending changes) > [ ... so he tried... ] > :wn > and got the message "wn: Not an editor command". There is surely some > other command that will do it, but why not the intuitive choice? The :wq command was a mistake and should be expelled from vi ASAP. For one thing, it invites the mistake Pierre described above. Plus, the :x command is superior: - it skips the write if the buffer was not [Modified] - it gives you a second chance if the write failed - it's shorter :-) - ZZ is mapped to :x. By the way, Pierre, the trick to get two ex commands on a line is to separate them by a |, e.g.: :w|n But :g and :! commands can have |s in their arguments, so they must be the last command on the line. If you find yourself typing :w|n all the time, you might want to :set autowrite and use :n! on those rare occasions when you don't want to save changes. Keep in mind that vi also autowrites when you stop it using ctrl-Z, use :stop! if you don't want to autowrite before stopping. Have a nice day, Hans Mulder hansm@cs.kun.nl