Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site ho95b.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!houxm!ho95b!wcs From: wcs@ho95b.UUCP (Bill Stewart) Newsgroups: net.text Subject: Re: Can vi / ex source beginning of text on startup ? Message-ID: <263@ho95b.UUCP> Date: Thu, 29-Nov-84 10:08:43 EST Article-I.D.: ho95b.263 Posted: Thu Nov 29 10:08:43 1984 Date-Received: Fri, 30-Nov-84 07:31:06 EST Organization: AT&T Bell Labs, Holmdel NJ Lines: 35 Chris Seiwald at politik asked about a file he saw with ex/vi commands at the beginning, and wondered whether this worked. It does. The documentation for this is in a report by Mark Horton describing the changes to vi versions 3.1 through 3.5. If the first 5 or last 5 lines of your file contain the following patterns, they will be executed when the file is read: [^:]*ex:valid-ex-commands-including-optional-spaces: [^:]*vi:valid-ex-commands-including-optional-spaces: For example, the line /* ex: set nu ai wm=0 window=23: */ at the beginning of a C program will set the modes to number, autoindent, nowrapmargin, window=23. The important things about the pattern seem to be: no colons before the ex or vi, and no space between the ex or vi and the following colon. Occasionally this feature will bite you. The classic problem is editing a password file where one of the first or last five users has a login ending in ex. tex:Rb.XX/MWDhlj6:801:1:Bob.from.Amarillo:/usr2/tex:/bin/ksh When you edit the file, vi complains that Rb.XX/MWDhlj6 is not a valid editor command, but generally keeps working. (It is possible to create uneditable files this way, or files that do serious damage to the reader. Periodic discussions occur about whether this is a feature or a misfeature; I think it's a very useful feature, but agree that it would be nice to have a vi option that disables/enables it. Bill Stewart -- Bill Stewart AT&T Bell Labs, Holmdel NJ 1-201-949-0705 ...!ihnp4!ho95b!wcs