Article View: comp.editors
Article #3342Re: Yet another vi question (solution)
From: M.B.BRILLIANT
Date: Wed, 12 Oct 1988 15:02
Date: Wed, 12 Oct 1988 15:02
28 lines
1590 bytes
1590 bytes
Sorry I came in late with this, but my curiosity was not aroused until I noticed that all gurus were stumped. There is a way to get vi to read a template before editing the file. The quirk is that vi will not execute the '+command' argument unless it successfully reads the file. I tried that with a simple '+map x p' argument, and the mapping did not take effect unless vi also received a file argument, and the named file already existed. The only excuse I could find for this quirk is that the manual page explains the +command argument by saying "The specified ex command is interpreted before editing begins." If no file is read in, there is nothing to edit, so editing never "begins," and +command is skipped. So you will not be able to name a new nonexistent file as the file argument for vi, and use the +command argument to read a template. The solution is to name the template file in the vi command, and use the +command argument to ask vi to change the file name. Thus (on the system I am working on) the command "vi '+r template' newfile" does not work, but the command "vi '+f newfile' template" does exactly what you want. Marty M. B. Brilliant houdi!marty1, homxc!marty
Technical Details
Message-ID:
<3779@homxc.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!whuts!homxb!homxc!martyReferences:
<270@tijc02.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!whuts!homxb!homxc!marty From: marty@homxc.UUCP (M.B.BRILLIANT) Newsgroups: comp.editors Subject: Re: Yet another vi question (solution) Summary: There is a way Message-ID: <3779@homxc.UUCP> Date: 12 Oct 88 15:02:34 GMT References: <270@tijc02.UUCP> Organization: AT&T Bell Laboratories, Holmdel Lines: 28