carl@mugwump.UK.Sun.COM (Carl Johnson - Sun EHQ - MIS) (01/30/91)
Greetings, Is there a way in vi to refer to the last file you tried to edit? For example if I do :e file.c and get an error because I haven't saved it can I then do the equivalent of :e! !$ Cheers, Carl.
tchrist@convex.COM (Tom Christiansen) (01/31/91)
From the keyboard of carl@mugwump.UK.Sun.COM (Carl Johnson - Sun EHQ - MIS): :Greetings, : Is there a way in vi to refer to the last file you tried to edit? For : example if I do :e file.c and get an error because I haven't saved it : can I then do the equivalent of :e! !$ :e!# if you're into that kind of thing, you might wish to set autowrite and writeany, and use :n to go to the next file. --tom -- "Hey, did you hear Stallman has replaced /vmunix with /vmunix.el? Now he can finally have the whole O/S built-in to his editor like he always wanted!" --me (Tom Christiansen <tchrist@convex.com>)
dattier@vpnet.chi.il.us (David W. Tamkin) (02/01/91)
carl@mugwump.UK.Sun.COM (Carl Johnson) wrote in <4729@male.EBay.Sun.COM>: | Is there a way in vi to refer to the last file you tried to edit? For | example if I do :e file.c and get an error because I haven't saved it | can I then do the equivalent of :e! !$ Is :e# what you're looking for? David Tamkin PO Box 7002 Des Plaines IL 60018-7002 dattier@vpnet.chi.il.us GEnie:D.W.TAMKIN CIS:73720,1570 MCIMail:426-1818 708 518 6769 312 693 0591
Dan_Bloch@TRANSARC.COM (02/01/91)
tchrist@convex.COM (Tom Christiansen) writes: > carl@mugwump.UK.Sun.COM (Carl Johnson - Sun EHQ - MIS) writes: > >> Is there a way in vi to refer to the last file you tried to edit? For >> example if I do :e file.c and get an error because I haven't saved it >> can I then do the equivalent of :e! !$ > > :e! # > > if you're into that kind of thing, you might wish to set autowrite > and writeany, and use :n to go to the next file. In a little more detail, # represents the "alternate filename," which is generally the last file you edited or referenced. Similarly % represents the current filname. These can be used in any command-mode command, e.g. :e! # as above, :!lpr % to print the file you're editing, :r # to read the alternate file into the current file, etc. If you set autowrite and you use :n instead of :e, your file gets saved automatically and you basically never have to type :w. Setting writeany doesn't do anything for you. Control-^ is a synonym for :n #. Dan Bloch dan@transarc.com P.S. Re repost: The original question was clear. Tom's response and this elaboration answer the question.