This is expected. Your complaint seems to stem from a confusion between "line separators" (the DOS and Windows concept) and "line endings" (the Unix and Vim concept). Let us explain how Vim does it:
Vim doesn't store the individual lines differently based on whether they had an end-of-line in the input. IIUC (but I might be wrong), each line is stored internally as a C string, ended by neither a CR nor a LF (nor both) but a null byte. This is why Vim must replace actual nulls in the file, usually by linefeeds, in order to avoid terminating those C strings early (see ":help NL-used-for-NUL"). Of course the last one of those C strings must be properly terminated too. When writing the file, Vim takes care of any translation required by a possible discrepancy between 'encoding' and 'fileencoding', and at the same time it writes the final end-of-line, or not, depending on the saved values of the following settings: • If 'binary' is off and 'fixeol' is on (the default) a final end-of-line is always written. (Older versions of Vim, where 'fixeol' is not defined, behave as if it were on. This option is a fairly recent invention, see the patch descriptions at http://ftp.vim.org/pub/vim/patches/7.4/ for details.) • If 'binary' is on, the local value of 'endofline' determines whether or not a final end-of-line will be written. It was set or cleared when reading, by the (present or missing, respectively) end-of-line marker at the end of the last line. • If 'binary' and 'fixeol' are both off, the file will have a final end-of-line if and only if it had one when reading. From reading the help I'm not sure if the value used is the local 'endofline' setting or some internal variable not accessible to vimscript. The 'list' mechanism is simpler: when 'list' is on, the 'listchars' value of "eol:" (if set: by default a dollar sign) is displayed in the screen cell immediately following the last character of every line. This is meant to show where the line ends, and I find it useful to check for end-of-line spaces, even in the last line, and that without cluttering the whole text (even where not at end-of-line) with disturbing (to me) "space:" placeholders. (When 'list' is on, hard tabs are always visible unless "tab:" is explicitly set to two spaces; if it is not set, tabs display as ^I). 'list' and 'listchars' take no notice of whether there was a final end-of-line in tyhe disk representation of the input file; they just display an "end-of-line marker" ($ or whatever you choose) "at the end of the line" (sic), i.e. (if I'm not mistaken) where they find the terminating null for the line in question. Best regards, Tony. On Thu, Dec 3, 2015 at 9:35 PM, <[email protected]> wrote: > Hi, today I discovered a strange issue that lead me to waste 2 hours of time, > since I rely on vim but it seems I discovered a bug. > > When working with files I usually put on end of line markers with the command > : set list . > Today I had a file with the last line without a LF character but though I had > enabled the line ending markers(with : set list) and put vim in binary mode, > it kept sowing a dollar sign at the end of the last line, as if a line mark > was there for real. Why vim shows an end of line when there is actually no > end of line ? > > Even opening with -b option I get the same result... > > To simulate just try with a simple perl script to write a single character on > a file: > > > open(FH, '>', 'file.txt'); > print FH 'a'; > close(FH); > > you will notice that VIM will keep showing the end of line sign. > > -- > -- > You received this message from the "vim_use" maillist. > Do not top-post! Type your reply below the text you are replying to. > For more information, visit http://www.vim.org/maillist.php > > --- > You received this message because you are subscribed to the Google Groups > "vim_use" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
