Thread View: comp.editors
4 messages
4 total messages
Started by Simon Ho Ki CHAN
Thu, 21 Jan 1993 06:14
A little question on vi
Author: Simon Ho Ki CHAN
Date: Thu, 21 Jan 1993 06:14
Date: Thu, 21 Jan 1993 06:14
18 lines
970 bytes
970 bytes
Hi, is there anybody who knows how to put the EOF marker at the end of the last line, instead of putting it in a new line? e.g I wanna create a file like the following blah, blah blah, blah<EOF> instead of blah, blah blah, blah <EOF> Thanks for advance. ___ ___ (__ ' ___ __ __ / ) / __ __ ) / / / ) / ) / ) / /__ ___) / ) ___/ / / / / (__/ / / (___/ / ( (__(_ / /
Re: A little question on vi
Author: nicholas.hounsome
Date: Thu, 21 Jan 1993 09:24
Date: Thu, 21 Jan 1993 09:24
26 lines
1220 bytes
1220 bytes
From article <1993Jan21.061448.25739@cdf.toronto.edu>, by g2chanhk@cdf.toronto.edu (Simon Ho Ki CHAN): > Hi, is there anybody who knows how to put the EOF marker at the end of > the last line, instead of putting it in a new line? e.g I wanna create a file > like the following > > blah, blah > blah, blah<EOF> > > instead of > > blah, blah > blah, blah > <EOF> > > Thanks for advance. It is not possible - vi is fundamentaly a line editor - its core is the ex part which is a line editor which is roughly based on ed which is a line editor. There is no EOF marker by the way (Well not in unix anyway). This is also the main reason why you cannot delete the newline with 'x' or 'X' as you can in character stream oriented editors such as emacs. Nick Hounsome
Re: A little question on vi
Author: John Mackin
Date: Thu, 21 Jan 1993 15:05
Date: Thu, 21 Jan 1993 15:05
59 lines
3040 bytes
3040 bytes
In article <1993Jan21.061448.25739@cdf.toronto.edu>, g2chanhk@cdf.toronto.edu (Simon Ho Ki CHAN) writes: > Hi, is there anybody who knows how to put the EOF marker at the end of > the last line, instead of putting it in a new line? e.g I wanna create a file > like the following > > blah, blah > blah, blah<EOF> > > instead of > > blah, blah > blah, blah > <EOF> Someone has made this point already, but I have a few things to add. The answer to the question is that this is impossible with vi. And as `someone' (what I wouldn't give for a better news-reading interface!) pointed out, there is no "EOF marker" in a UNIX file. A UNIX file is an exact number of characters (bytes, octets) long and therefore has no requirement for an "EOF marker" such as is needed on some filesystems where files don't have an exact length in bytes, but only a sector or block count. (Note, all my remarks here apply to UNIX. If the original poster is using vi on something else, all bets are off.) There is a good reason why this is impossible. The reason is that vi is a text editor, for editing text files. A well-formed UNIX text file consists of zero or more lines. A line consists of zero or more non-null characters followed by a terminating newline character. Hence, a non-empty file with no terminal newline is not a well-formed UNIX text file. You don't want to create one of those, since (unfortunately) far too many UNIX tools will behave in `interesting' ways when presented with one of them. Similarly, you don't want to treat files with embedded nulls as text -- I'll never forget the day grep failed to match patterns that were indeed matched by strings in the file, because the file also had nulls in it. (There is also a well-known bug in many versions of vi to do with this. The above definition of a text file certainly admits the null (that is, zero-length or empty) file as a valid text file, as it must. Unfortunately, many versions of vi don't allow you to create the null file, or indeed operate on it sensibly. You can read it in, but it immediately becomes a one-line file.) This is not to say that a text editor _mustn't_ let you create a file without a terminal newline. Indeed, I tend to come down on the side of never second-guessing the user. But, I can see where the idea came from, and it's not wholly without merit. -- John Mackin <john@civil.su.oz.au> Knox's box is a 286. Fox in Socks does hacks and tricks Knox's box is hard to fix. To fix poor Knox's box for kicks.
Re: A little question on vi
Author: DWT
Date: Thu, 21 Jan 1993 15:44
Date: Thu, 21 Jan 1993 15:44
27 lines
1384 bytes
1384 bytes
g2chanhk@cdf.toronto.edu (Simon Ho Ki CHAN) asked in <1993Jan21.061448.25739@cdf.toronto.edu>: | Hi, is there anybody who knows how to put the EOF marker at the end of | the last line, instead of putting it in a new line? e.g I wanna create a file | like the following | | blah, blah | blah, blah<EOF> | | instead of | | blah, blah | blah, blah | <EOF> vi is adamant about closing a file with a trailing newline (the exception being a file consisting of only one newline, which vi insists on writing out as an empty file) when it writes a file out. You can use another editor or, if the last line is short, leave it off, exit vi, and echo -n "text" >> file with BSD echo or echo "text\c" >> file with System V echo. However, you'd have to do that again every time you let vi write the file again. David W. Tamkin Box 59297 Northtown Station, Illinois 60659-0297 dattier@ddsw1.mcs.com CompuServe: 73720,1570 MCI Mail: 426-1818
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads