tr@SAMADAMS.PRINCETON.EDU (Tom Reingold) (12/05/90)
I discovered the "modelines" feature of vi. It's really great. In my ~/.exrc, I have "set modelines" and I can have a vi command in my text file so that the file can have its individual settings. For example, a C program of mine has indentations at 4 characters instead of 8, so I set shiftwidth to 4. The problem is that anything I set with one of these commands in my file seems to tell vi that the file has been modified immediately upon entering the editor. So I can't use ":q" or "ZZ" to quit. If I do, it will write out the file unnecessarily, making me recompile unnecessarily. Is there a way around this problem? -- Tom Reingold tr@samadams.princeton.edu OR ...!princeton!samadams!tr "Warning: Do not drive with Auto-Shade in place. Remove from windshield before starting ignition."
mayoff@cs.utexas.edu (Robert Mayoff) (12/06/90)
In article <9012051559.AA01923@samadams.Princeton.EDU> tr@SAMADAMS.PRINCETON.EDU (Tom Reingold) writes: >I discovered the "modelines" feature of vi. It's really great. In my I don't have an answer to the question you asked, but let me point out something. Let's I create a file containing this: :ex:!rm -Rf $HOME/* (I think that's what the modeline looks like, right?) Suppose you edit the file. You've just deleted all your files, unless your version of vi has had this hole plugged. -- /_ rob <mayoff@cs.utexas.edu> /_ Fun things to do with UNIX (#72 in a series): / cat /dev/zero > /dev/null
ed@lvw6.lvw.fac.com (Ed Allen) (12/08/90)
In article <9012051559.AA01923@samadams.Princeton.EDU> tr@SAMADAMS.PRINCETON.EDU (Tom Reingold) writes: > The problem is that anything I set with one of these commands in my > file seems to tell vi that the file has been modified immediately upon > entering the editor. So I can't use ":q" or "ZZ" to quit. If I do, it > will write out the file unnecessarily, making me recompile > unnecessarily. > > Is there a way around this problem? > -- Can't you add another modeline which does something like: :ex:%w /dev/null That should "write" your changes to the bit-bucket. -- Never trust a man who wears white shoes. | Ed Allen Vote Libertarian... Scare the Hell out of 'em. | Loral Command & Contr. Sys. "Sure the game is rigged! But if you don't play | ed@lvw6.lvw.loral.com you can't win!"