home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / editors / 3265 < prev    next >
Encoding:
Text File  |  1993-01-21  |  2.9 KB  |  72 lines

  1. Newsgroups: comp.editors
  2. Path: sparky!uunet!munnari.oz.au!metro!physiol.su.OZ.AU!john
  3. From: john@civil.su.oz.au (John Mackin)
  4. Subject: Re: A little question on vi
  5. Message-ID: <1993Jan21.150505.28644@physiol.su.OZ.AU>
  6. Summary: vi is a _text_ editor
  7. Sender: john@physiol.su.OZ.AU (John Mackin)
  8. Organization: Chickenhawk Software
  9. References: <1993Jan21.061448.25739@cdf.toronto.edu>
  10. Date: Thu, 21 Jan 1993 15:05:05 GMT
  11. Lines: 59
  12.  
  13. In article <1993Jan21.061448.25739@cdf.toronto.edu>,
  14.     g2chanhk@cdf.toronto.edu (Simon Ho Ki CHAN) writes:
  15.  
  16. >    Hi, is there anybody who knows how to put the EOF marker at the end of 
  17. > the last line, instead of putting it in a new line? e.g I wanna create a file 
  18. > like the following
  19. >
  20. >        blah, blah
  21. >        blah, blah<EOF>
  22. >
  23. >    instead of
  24. >
  25. >        blah, blah
  26. >        blah, blah
  27. >        <EOF>
  28.  
  29. Someone has made this point already, but I have a few things to add.
  30.  
  31. The answer to the question is that this is impossible with vi.  And
  32. as `someone' (what I wouldn't give for a better news-reading
  33. interface!) pointed out, there is no "EOF marker" in a UNIX file.
  34. A UNIX file is an exact number of characters (bytes, octets)
  35. long and therefore has no requirement for an "EOF marker" such as is
  36. needed on some filesystems where files don't have an exact
  37. length in bytes, but only a sector or block count.  (Note,
  38. all my remarks here apply to UNIX.  If the original poster
  39. is using vi on something else, all bets are off.)
  40.  
  41. There is a good reason why this is impossible.  The reason is that
  42. vi is a text editor, for editing text files.  A well-formed UNIX
  43. text file consists of zero or more lines.  A line consists of
  44. zero or more non-null characters followed by a terminating
  45. newline character.  Hence, a non-empty file with no terminal newline
  46. is not a well-formed UNIX text file.  You don't want to
  47. create one of those, since (unfortunately) far too many
  48. UNIX tools will behave in `interesting' ways when presented
  49. with one of them.  Similarly, you don't want to treat files
  50. with embedded nulls as text -- I'll never forget the day grep
  51. failed to match patterns that were indeed matched by strings
  52. in the file, because the file also had nulls in it.
  53.  
  54. (There is also a well-known bug in many versions of vi to do
  55. with this.  The above definition of a text file certainly
  56. admits the null (that is, zero-length or empty) file as a
  57. valid text file, as it must.  Unfortunately, many versions
  58. of vi don't allow you to create the null file, or indeed
  59. operate on it sensibly.  You can read it in, but it immediately
  60. becomes a one-line file.)
  61.  
  62. This is not to say that a text editor _mustn't_ let you
  63. create a file without a terminal newline.  Indeed, I tend
  64. to come down on the side of never second-guessing the user.
  65. But, I can see where the idea came from, and it's not
  66. wholly without merit.
  67.  
  68. -- 
  69. John Mackin <john@civil.su.oz.au>
  70. Knox's box is a 286.                 Fox in Socks does hacks and tricks
  71. Knox's box is hard to fix.           To fix poor Knox's box for kicks.
  72.