From feabc1c98cb077f60fde1a14e8540f2cf99eb8d2 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 29 Oct 2022 09:03:15 +0800 Subject: vim-patch:9.0.0816: CTRL-Z at end of file is always dropped Problem: CTRL-Z at end of file is always dropped. Solution: Add the 'endoffile' option, like the 'endofline' option. (closes vim/vim#11408, closes vim/vim#11397) Cherry-pick test_fixeol.vim changes from patch 8.2.1432. Cherry-pick 'endoffile' changes from latest Vim runtime update. https://github.com/vim/vim/commit/fb0cf2357e0c85bbfd9f9178705ad8d77b6b3b4e vim-patch:f0b567e32a46 Revert unintended Makefile change https://github.com/vim/vim/commit/f0b567e32a462fe838170a202919d18b53eff987 vim-patch:72c8e3c070b3 Fix wrong struct access for member. https://github.com/vim/vim/commit/72c8e3c070b30f82bc0d203a62c168e43a13e99b vim-patch:3f68a4136eb9 Add missing entry for the 'endoffile' option. https://github.com/vim/vim/commit/3f68a4136eb99840d739af5133ab31948f273f63 Co-authored-by: Bram Moolenaar --- runtime/doc/options.txt | 11 ++++++++++- runtime/doc/quickref.txt | 1 + runtime/optwin.vim | 5 ++++- 3 files changed, 15 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index a04d02946d..4718876b29 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -2135,6 +2135,15 @@ A jump table for the options with a short description can be found at |Q_op|. See 'fileencoding' to control file-content encoding. + *'endoffile'* *'eof'* *'noendoffile'* *'noeof'* +'endoffile' 'eof' boolean (default on) + local to buffer + Indicates that a CTRL-Z character was found at the end of the file + when reading it. Normally only happens when 'fileformat' is "dos". + 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. + *'endofline'* *'eol'* *'noendofline'* *'noeol'* 'endofline' 'eol' boolean (default on) local to buffer @@ -2490,7 +2499,7 @@ A jump table for the options with a short description can be found at |Q_op|. 'fixendofline' 'fixeol' boolean (default on) local to buffer When writing a file and this option is on, at the end of file - will be restored if missing. Turn this option off if you want to + will be restored if missing. Turn this option off if you want to preserve the situation from the original file. When the 'binary' option is set the value of this option doesn't matter. diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt index 2f91498857..e4a3dae08b 100644 --- a/runtime/doc/quickref.txt +++ b/runtime/doc/quickref.txt @@ -689,6 +689,7 @@ Short explanation of each option: *option-list* 'display' 'dy' list of flags for how to display text 'eadirection' 'ead' in which direction 'equalalways' works 'encoding' 'enc' encoding used internally +'endoffile' 'eof' write CTRL-Z at end of the file 'endofline' 'eol' write for last line in file 'equalalways' 'ea' windows are automatically made the same size 'equalprg' 'ep' external program to use for "=" command diff --git a/runtime/optwin.vim b/runtime/optwin.vim index 57e5392b98..db21066819 100644 --- a/runtime/optwin.vim +++ b/runtime/optwin.vim @@ -1,7 +1,7 @@ " These commands create the option window. " " Maintainer: Bram Moolenaar -" Last Change: 2022 Oct 15 +" Last Change: 2022 Oct 28 " If there already is an option window, jump to that one. let buf = bufnr('option-window') @@ -956,6 +956,9 @@ call BinOptionL("bin") call AddOption("endofline", gettext("last line in the file has an end-of-line")) call append("$", "\t" .. s:local_to_buffer) call BinOptionL("eol") +call AddOption("endoffile", gettext("last line in the file followed by CTRL-Z")) +call append("$", "\t" .. s:local_to_buffer) +call BinOptionL("eof") call AddOption("fixendofline", gettext("fixes missing end-of-line at end of text file")) call append("$", "\t" .. s:local_to_buffer) call BinOptionL("fixeol") -- cgit