From owner-freebsd-questions@FreeBSD.ORG Tue Jan 27 07:50:57 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id ADDFE16A4CE for ; Tue, 27 Jan 2004 07:50:57 -0800 (PST) Received: from mxfep01.bredband.com (mxfep01.bredband.com [195.54.107.70]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4BEDA43D2F for ; Tue, 27 Jan 2004 07:50:41 -0800 (PST) (envelope-from dion@bredband.net) Received: from Hecate.my.hell ([213.113.217.184] [213.113.217.184]) by mxfep01.bredband.com with SMTP id <20040127155040.HRPP13434.mxfep01.bredband.com@Hecate.my.hell>; Tue, 27 Jan 2004 16:50:40 +0100 Date: Tue, 27 Jan 2004 16:50:01 +0100 From: Peder Blom To: rob_spellberg Message-Id: <20040127165001.7f531541.dion@bredband.net> In-Reply-To: <40158DB7.1020409@emailrob.com> References: <40158DB7.1020409@emailrob.com> X-Mailer: Sylpheed version 0.9.8a (GTK+ 1.2.10; i386-portbld-freebsd4.8) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit cc: questions@freebsd.org Subject: Re: [kinda ot] writing the date into a file when saving it X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Jan 2004 15:50:57 -0000 On Mon, 26 Jan 2004 15:59:19 -0600 rob_spellberg wrote: > dear sir or madam --- > > this may be a vi question, but i'd like to be editor-independent, if > possible. > > i want to self-document source code files when i write them to disk. > > this would include such things as path and modification time. > > ideally, within vi, i would like to have :w run a script [ that i > would write ] > that does exactly what i want. > > for years, i've been doing this more or less haphazardly during > development, > until i was satisfied that the file was in its final form. > then i would manually get it right and leave it alone. > but i'm writing too much right now to keep doing this manually and > i'm something of a nut for documentation. > > its easy enough to write a sed script to find a unique string and do a > replacement. its only slightly more involved to write a glorified > version of touch > [ which is kinda what i want, actually ]. > > maybe what i want is to go into vi [ or ex, or wherever ], > find where :w is processed and cause it to look for a script to > run. > > i know about :so. > i know about !command. > neither are really "it". > > i've been googling for about an hour and coming up almost completely > empty. maybe there's a jargon word for what i want that i don't know. > > so to get to the question: what do you folks do? > > rob spellberg > woodstock, illinois > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to > "freebsd-questions-unsubscribe@freebsd.org" I guess this is not what you are after, but have you considered mapping keys in vi? E.g. something like :map = 1GO^[!!date;whoami;hostname^M1G3J:w^M Now, pressing "=" in command mode adds a line at the top of the file with current date, user and host, then saves the file. You could be creative with !command, write your own script or c-program to generate input.