Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ll-xn!husc6!necntc!custom!boykin From: boykin@custom.UUCP (Joseph Boykin) Newsgroups: comp.unix.wizards Subject: Re: Undocumented vi feature Message-ID: <756@custom.UUCP> Date: Thu, 18-Jun-87 21:26:15 EDT Article-I.D.: custom.756 Posted: Thu Jun 18 21:26:15 1987 Date-Received: Mon, 22-Jun-87 01:17:36 EDT References: <219@ausmelb.OZ> Organization: Custom Software Systems; Natick, MA Lines: 28 Keywords: vi/ex commands in a text file Summary: Use "mode lines" In article <219@ausmelb.OZ>, dak@ausmelb.OZ (David Kruger) writes: > A UNIX guru once told me that it is possible to somehow enter vi/ex commands at > the top of a text file so that when you `vi' the file, the commands are > executed. Does anybody out there know how to do it? > > Thanks in advance, There is a feature within UNIX VI (and PC/VI) called "mode lines" which is what you are looking for. It was present, but not documented in UNIX VI version 3.7. They were documented for version 3.9 (SVR2). Essentially you put some magic anywhere within the first or last five lines of your file with EX commands in it. The magic is either "ex:" or "vi:" followed by the command, followed by another colon. That is, for your case you would want a mode line which looks like this: vi: set nonu nolist : Mode lines are processed after both global and local initialization (EXINIT and .exrc file(s)), hence the mode line will override your EXINIT and .exrc entries. If you have PC/VI, mode lines are documented in Chapter 4, section 4.8.2. Joe Boykin Custom Software Systems ...necntc!custom!boykin