patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place

Problem:    If 'endofline' is set the CTRL-Z may be written in the wrong
            place.
Solution:   Write CTRL-Z at the end of the file.  Update the help to explain
            the possibilities better. (Ken Takata, closes #11486)
This commit is contained in:
K.Takata
2022-11-01 20:36:19 +00:00
committed by Bram Moolenaar
parent 8e0ccb6bc2
commit 3af982196b
6 changed files with 136 additions and 19 deletions

View File

@ -578,6 +578,43 @@ single <NL> characters are unexpectedly replaced with <CR><NL>.
You can encrypt files that are written by setting the 'key' option. This
provides some security against others reading your files. |encryption|
END OF LINE AND END OF FILE *eol-and-eof*
Vim has several options to control the file format:
'fileformat' the <EOL> style: Unix, DOS, Mac
'endofline' whether the last line ends with a <EOL>
'endooffile' whether the file ends with a CTRL-Z
'fixendofline' whether to fix eol and eof
The first three values are normally detected automatically when reading the
file and are used when writing the text to a file. While editing the buffer
it looks like every line has a line ending and the CTRL-Z isn't there (an
exception is when 'binary' is set, it works differently then).
The 'fixendofline' option can be used to choose what to write. You can also
change the option values to write the file differently than how it was read.
Here are some examples how to use them.
If you want files in Unix format (every line NL terminated): >
setl ff=unix fixeol
You should probably do this on any Unix-like system. Also modern MS-Windows
systems tend to work well with this. It is recommended to always use this
format for Vim scripts.
If you want to use an old MS-DOS file in a modern environment, fixing line
endings and dropping CTRL-Z, but keeping the <CR><NL> style <EOL>: >
setl ff=dos fixeol
This is useful for many MS-Windows programs, they regularly expect the
<CR><NL> line endings.
If you want to drop the final <EOL> and add a final CTRL-Z (e.g. for an old
system like CP/M): >
setl ff=dos nofixeol noeol eof
If you want to preserve the fileformat exactly as-is, including any final
<EOL> and final CTRL-Z: >
setl nofixeol
==============================================================================
3. The argument list *argument-list* *arglist*