diff options
author | K.Takata <kentkt@csc.jp> | 2022-11-01 20:36:19 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-11-01 20:36:19 +0000 |
commit | 3af982196b1b973e953c35351961f2a96fe34172 (patch) | |
tree | 8b2bc31d033187b17b4c5fb6e51350f833cd984b /runtime/doc | |
parent | 8e0ccb6bc21a446e5c6375b7fdf200fb53a129da (diff) |
patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong placev9.0.0826
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)
Diffstat (limited to 'runtime/doc')
-rw-r--r-- | runtime/doc/editing.txt | 37 | ||||
-rw-r--r-- | runtime/doc/options.txt | 3 |
2 files changed, 40 insertions, 0 deletions
diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt index 522831f992..e5661b1bb5 100644 --- a/runtime/doc/editing.txt +++ b/runtime/doc/editing.txt @@ -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* diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 0a4df61dfa..bdc473df3e 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -3056,6 +3056,7 @@ A jump table for the options with a short description can be found at |Q_op|. When writing a file and this option is off and the 'binary' option is on, or 'fixeol' option is off, no CTRL-Z will be written at the end of the file. + See |eol-and-eof| for example settings. *'endofline'* *'eol'* *'noendofline'* *'noeol'* 'endofline' 'eol' boolean (default on) @@ -3071,6 +3072,7 @@ A jump table for the options with a short description can be found at |Q_op|. to remember the presence of a <EOL> for the last line in the file, so that when you write the file the situation from the original file can be kept. But you can change it if you want to. + See |eol-and-eof| for example settings. *'equalalways'* *'ea'* *'noequalalways'* *'noea'* 'equalalways' 'ea' boolean (default on) @@ -3466,6 +3468,7 @@ A jump table for the options with a short description can be found at |Q_op|. When the 'binary' option is set the value of this option doesn't matter. See the 'endofline' option. + See |eol-and-eof| for example settings. *'fkmap'* *'fk'* *'nofkmap'* *'nofk'* 'fkmap' 'fk' boolean (default off) |