Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!pilchuck!ssc!fyl From: fyl@ssc.UUCP (Phil Hughes) Newsgroups: comp.editors Subject: including filename with vi Message-ID: <484@ssc.UUCP> Date: 2 Nov 90 18:33:28 GMT Organization: SSC, Inc., Seattle, WA Lines: 38 A friend just asked how to include the name of the current file in vi. In other words, he wants the current file pathname inserted into the text for reference purposes. I couldn't think of how to do it. I wrote the shell script below as a nasty hack to solve the problem but it seems there must be a vi'ish way to do it. ----------nasty hack follows-------------- : nvi # create new file and put filename into it # call with: # nvi filename # make sure nvi was called with one argument if [ $# -ne 1 ] ; then echo "usage: nvi filename" exit 1 fi # make sure specified file doesn't exist if [ -f "$1" ] ; then echo "$0: $1 already exists" exit 1 fi # prepend path to filename if it doesn't start with a / if [ `expr $1 : "\/"` -eq 1 ] ; then pn=$1 else pn=`pwd`/$1 fi # create the file with a filename line in it echo File: $pn >$pn # invoke vi vi $pn -- Phil Hughes, SSC, Inc. P.O. Box 55549, Seattle, WA 98155 (206)FOR-UNIX uunet!pilchuck!ssc!fyl or attmail!ssc!fyl (206)527-3385