scott@tekcrl.LABS.TEK.COM (Scott Huddleston) (09/23/89)
When editing multiple files in vi, I'd like a faster(*) way to write changes and move on to the next file than :w RETURN :n RETURN or ZZ:n RETURN. Is there a faster way? Thanx in advance. (*) faster in terms of typing speed, esp. fewer shift/unshift changes. -- Scott Huddleston testing the semantics of the ".signature" file
kinzler@iuvax.cs.indiana.edu (Stephen Kinzler) (09/23/89)
scott@tekcrl.LABS.TEK.COM (Scott Huddleston) writes: >When editing multiple files in vi, I'd like a faster(*) way to write >changes and move on to the next file than :w RETURN :n RETURN or >ZZ:n RETURN. Is there a faster way? Thanx in advance. This is pretty much what macros were made for. Here's mine: map q :w^M:n^M (the ^M's are really carriage returns, prefaced with ctrl-v) Put this in your EXINIT environment variable or your ~/.exrc file. ------------------------------------------------------------------------ | ., >{~) ['} / Stephen Kinzler \ + < : ~$[~{}== | | % > %()}@! ' / kinzler@iuvax.cs.indiana.edu \ '}~{ >' & )<} | | <@"??{.,'} / {ames,rutgers,att}!iuvax!kinzler \ &"(&@+}<+;@) | | ])"} +{) / Indiana Univ Dept of Computer Science \ @ }[^??^&. | ------------------------------------------------------------------------
bitbug@lonewolf.sun.com (James Buster) (09/23/89)
In article <26465@iuvax.cs.indiana.edu> kinzler@iuvax.cs.indiana.edu (Stephen Kinzler) writes: >>scott@tekcrl.LABS.TEK.COM (Scott Huddleston) writes: >>When editing multiple files in vi, I'd like a faster(*) way to write >>changes and move on to the next file than :w RETURN :n RETURN or >>ZZ:n RETURN. Is there a faster way? Thanx in advance. > >This is pretty much what macros were made for. Here's mine: > > map q :w^M:n^M > (the ^M's are really carriage returns, prefaced with ctrl-v) > >Put this in your EXINIT environment variable or your ~/.exrc file. There is a much better way. Set autowrite (the "aw" variable) in your EXINIT environment variable or .exrc. This will cause the file to be automatically written when the :n command is given. If you have job control, it will also cause your file to be written automatically when ^Z is typed. If you use the ^^ command (that's control-caret), the file will also be written when going to the alternate file. >------------------------------------------------------------------------ >| ., >{~) ['} / Stephen Kinzler \ + < : ~$[~{}== | >| % > %()}@! ' / kinzler@iuvax.cs.indiana.edu \ '}~{ >' & )<} | >| <@"??{.,'} / {ames,rutgers,att}!iuvax!kinzler \ &"(&@+}<+;@) | >| ])"} +{) / Indiana Univ Dept of Computer Science \ @ }[^??^&. | >------------------------------------------------------------------------ -- -------------------------------------------- James Buster Mad Hacker Extraordinaire bitbug@lonewolf.ebay.sun.com bitbug%lonewolf@sun.com sun.com!lonewolf!bitbug --------------------------------------------
les@chinet.chi.il.us (Leslie Mikesell) (09/24/89)
In article <BITBUG.89Sep22183111@lonewolf.sun.com> bitbug@lonewolf.sun.com (James Buster) writes: >There is a much better way. Set autowrite (the "aw" variable) in your >EXINIT environment variable or .exrc. This will cause the file to be >automatically written when the :n command is given. If you have job >control, it will also cause your file to be written automatically >when ^Z is typed. If you use the ^^ command (that's control-caret), >the file will also be written when going to the alternate file. Keep in mind that aw also causes a the file to be automatically written when you do a shell escape. I have been bitten by this a few times when I realized during an editing session that I had made substantial changes and should have made a backup copy of the original. No problem, just: :!cp % %.O except that with autowrite enabled, the current buffer is written out before the shell escape, so goodbye original file... Les Mikesell
irf@kuling.UUCP (Bo Thide') (09/25/89)
In article <4728@tekcrl.LABS.TEK.COM> scott@tekcrl.LABS.TEK.COM (Scott Huddleston) writes: >When editing multiple files in vi, I'd like a faster(*) way to write >changes and move on to the next file than :w RETURN :n RETURN or >ZZ:n RETURN. Is there a faster way? Thanx in advance. > If the alternative filename is known to 'vi' (i.e., you have been there before during your editing session) you can use <CTRL>-^ to toggle between the alternative file/buffer and the current one. If you have set the autowrite option the changes made in the file you just left will be recorded. Another possibility would be to use tags. ^ Bo Thide'-------------------------------------------------------------- | | Swedish Institute of Space Physics, S-755 91 Uppsala, Sweden |I| [In Swedish: Institutet f|r RymdFysik, Uppsalaavdelningen (IRFU)] |R| Phone: (+46) 18-403000. Telex: 76036 (IRFUPP S). Fax: (+46) 18-403100 /|F|\ INTERNET: bt@irfu.se UUCP: ...!uunet!sunic!irfu!bt ~~U~~ -----------------------------------------------------------------sm5dfw
jonathan@cs.keele.ac.uk (Jonathan Knight) (09/25/89)
From article <9652@chinet.chi.il.us>, by les@chinet.chi.il.us (Leslie Mikesell): > > Keep in mind that aw also causes a the file to be automatically written > when you do a shell escape. I have been bitten by this a few times when > I realized during an editing session that I had made substantial changes > and should have made a backup copy of the original. No problem, just: > :!cp % %.O > except that with autowrite enabled, the current buffer is written out > before the shell escape, so goodbye original file... Yep. However if you want to get out of this (or if you've forgotten to give yourself write permission to the file your editing) then just :sh and vi will give you a shell without saving the file. Now you can undo the damage. -- ______ JANET :jonathan@uk.ac.keele.cs Jonathan Knight, / BITNET:jonathan%cs.kl.ac.uk@ukacrl Department of Computer Science / _ __ other :jonathan@cs.keele.ac.uk University of Keele, Keele, (_/ (_) / / UUCP :...!ukc!kl-cs!jonathan Staffordshire. ST5 5BG. U.K.
morrell@hpsal2.HP.COM (Michael Morrell) (09/26/89)
/ hpsal2:comp.editors / les@chinet.chi.il.us (Leslie Mikesell) / 12:33 am Sep 24, 1989 / In article <BITBUG.89Sep22183111@lonewolf.sun.com> bitbug@lonewolf.sun.com (James Buster) writes: >There is a much better way. Set autowrite (the "aw" variable) in your >EXINIT environment variable or .exrc. This will cause the file to be >automatically written when the :n command is given. If you have job >control, it will also cause your file to be written automatically >when ^Z is typed. Keep in mind that aw also causes a the file to be automatically written when you do a shell escape. I have been bitten by this a few times when I realized during an editing session that I had made substantial changes and should have made a backup copy of the original. No problem, just: :!cp % %.O except that with autowrite enabled, the current buffer is written out before the shell escape, so goodbye original file... Les Mikesell ---------- I agree with Les. It's too easy to be bitten by the autowrite "feature". I also have a map (I map ^N to :w^M:n^M) and it works great. Michael
nolan@tut.cis.ohio-state.edu (Michael C Nolan) (09/27/89)
I noticed that at least one clone-vi for a PC includes :wn as an obviously useful and easy to use (and guess that it might exist) item. Too bad it doesn't.
ge@mcnc.org (George Entenman) (09/29/89)
In article <BITBUG.89Sep22183111@lonewolf.sun.com> bitbug@lonewolf.sun.com (James Buster) writes: >There is a much better way. Set autowrite (the "aw" variable) in your >EXINIT environment variable or .exrc. This will cause the file to be >automatically written when the :n command is given. If you have job >control, it will also cause your file to be written automatically >when ^Z is typed. If you use the ^^ command (that's control-caret), >the file will also be written when going to the alternate file. My office mate typically codes C by using the following loop: repeat until satisfied with result invoke vi on a C file edit the file write the file quit vi compile But one day a couple of weeks ago, she started up vi on a C file and then used control-Z to stop it. She then started her typical work loop and worked for about 3 hours, making extensive changes on the original C file. After finishing, she noticed a vi job sitting in background and typed 'fg'. Seeing that the file was a very old version, she typed ':q' to get out. 3 hours of work were gone! There was lots of screaming that I won't describe here. It turned out that her .login file, which she had borrowed from someone, set EXINIT to autowrite. I don't think that autowrite should ever be set automatically. But then, I always alias 'rm' to be 'rm -i'. If I can't trust me, should you? ################################################################################ # # # George Entenman (ge@mcnc.org) # # # # The Microelectronics Center of North Carolina # # P.O. Box 12889 # # Research Triangle Park, NC 27709 # # 919/248-1953 # # # ################################################################################
les@chinet.chi.il.us (Leslie Mikesell) (10/02/89)
In article <5486@alvin.mcnc.org> ge@mcnc.org.UUCP (George Entenman) writes: >My office mate typically codes C by using the following loop: > > repeat until satisfied with result > invoke vi on a C file > edit the file > write the file > quit vi > compile I usually do this: invoke vi on a C file repeat until satisfied with result edit the file write the file position to end of buffer read in lint's comments (:r !lint % ) end repeat quit vi compile Les Mikesell
wsinkees@lso.win.tue.nl (Kees Huizing) (10/09/89)
ge@mcnc.org (George Entenman) writes: >In article <BITBUG.89Sep22183111@lonewolf.sun.com> bitbug@lonewolf.sun.com (James Buster) writes: > ... >But one day a couple of weeks ago, she started up vi on a C file and >then used control-Z to stop it. She then started her typical work loop >and worked for about 3 hours, making extensive changes on the original C >file. >After finishing, she noticed a vi job sitting in background and typed >'fg'. Seeing that the file was a very old version, she typed ':q' to >get out. >3 hours of work were gone! There was lots of screaming that I won't >describe here. It turned out that her .login file, which >she had borrowed from someone, set EXINIT to autowrite. How is this possible? If you type ':q' nothing is written by our vi! I quit with '^Z' many times and sometimes I accidentally start up a new vi-job on the same file. When I see the old jobs hanging around, I reactivate them and silently quit with ':q' without any harm. Even if you have autowrite on, vi warns you when you quit this way and some changes have not been written yet. So, what is going on here? If there is something harmful in autowrite, I would really like to know, since I use it very heavily, quitting with '^Z' and executing latex etc. from within vi with ':!compile' . Can someone explain me the danger of my ways? Kees Huizing -- Kees Huizing - Eindhoven Univ of Techn - Dept Math & Comp Sc - The Netherlands DOMAIN: wsinkees@win.tue.nl BITNET: wsdckeesh@heitue5 FAX: +31-40-436685
ge@mcnc.org (George Entenman) (10/10/89)
In article <455@tuewsd.lso.win.tue.nl> wsinkees@lso.win.tue.nl (Kees Huizing) writes: >ge@mcnc.org (George Entenman) writes: > >>In article <BITBUG.89Sep22183111@lonewolf.sun.com> bitbug@lonewolf.sun.com (James Buster) writes: > >> ... >>But one day a couple of weeks ago, she started up vi on a C file and >>then used control-Z to stop it. She then started her typical work loop >>and worked for about 3 hours, making extensive changes on the original C >>file. > >>After finishing, she noticed a vi job sitting in background and typed >>'fg'. Seeing that the file was a very old version, she typed ':q' to >>get out. > >>3 hours of work were gone! There was lots of screaming that I won't >>describe here. It turned out that her .login file, which >>she had borrowed from someone, set EXINIT to autowrite. > >How is this possible? If you type ':q' nothing is written by our vi! >I quit with '^Z' many times and sometimes I accidentally start up a new >vi-job on the same file. When I see the old jobs hanging around, I >reactivate them and silently quit with ':q' without any harm. >Even if you have autowrite on, vi warns you when you quit this way and some >changes have not been written yet. I checked again, and you are correct about ':q'. I guess my office mate must have either used '^Z' again, escaped to a shell for some reason, or simply answered yes after entering ':q'. >So, what is going on here? If there is something harmful in autowrite, I >would really like to know, since I use it very heavily, quitting with '^Z' >and executing latex etc. from within vi with ':!compile' . Can someone >explain me the danger of my ways? I still feel that '^Z' should be 'safer' than ':q'. Your method requires you to mentally redefine '^Z' and ':!' as meaning to write the file. Perhaps this is not as dangerous as I think. Certainly, it would take me a while to get used to it. And, I still can't help thinking that it might get you someday. Let's see if I can imagine a scenario. Suppose that you have an old vi job hanging around, forgotten. Suppose that you are busy using '^Z' and 'fg' to get in and out of your file. Suppose you quit that vi and don't notice the other vi in background. And suppose that you absent mindedly type 'fg' to get back into vi. If you don't notice that this is an old version of the file, you are in danger of wiping out your work with another '^Z'. Tell me if this ever happens to you! ................................................................................ George Entenman ge@mcnc.org
wsinkees@lso.win.tue.nl (Kees Huizing) (10/12/89)
ge@mcnc.org (George Entenman) writes: (talking about the dangers of the option 'autowrite' in vi) > And, I still can't help thinking that it might get you someday. > Let's see if I can imagine a scenario. Suppose that you have an > old vi job hanging around, forgotten. Suppose that you are busy > using '^Z' and 'fg' to get in and out of your file. Suppose you > quit that vi and don't notice the other vi in background. And > suppose that you absent mindedly type 'fg' to get back into vi. > If you don't notice that this is an old version of the file, you > are in danger of wiping out your work with another '^Z'. Tell > me if this ever happens to you! > ge@mcnc.org I must admit, this is a danger. I think that this happened to me when I had just learned about '^Z' and 'autowrite'. But I so seldom use 'ZZ' nowadays, that I don't fall into this trap anymore. My usual way to quit vi is now to type two times 'logout' :-) By the way, for those who love '^Z' and 'autowrite', here's a way to "suspend" vi even from input mode: map map! The ^X can be any key you don't use. It is needed to avoid "tail recursion". Kees -- Kees Huizing - Eindhoven Univ of Techn - Dept Math & Comp Sc - The Netherlands DOMAIN: wsinkees@win.tue.nl BITNET: wsdckeesh@heitue5 FAX: +31-40-436685