I'm using Vim 8.2 to edit some text files for a very old MSX-DOS system; these have a Ctrl-Z (0x1A) character after the final CR LF to indicate the end of the file, as is usual with CP/M and similar disk operating systems.
I normally edit with
nofixendofline and in this case I see, after the last line of text and trailing
<0d>, a line with the Ctrl-Z character, displayed as
<1a>. I can edit and save and, so long as I manually add the CR at the end of any new lines I add, all is fine.
When I switch to DOS fileformat and re-read the file (
:set fileformats=dos | e) the
<0d> characters disappear (as expected), and so does the final
<1a> character. But unlike the CRs, the Ctrl-Z is not added back in when I write out the file. (I'm writing it immediately after the above command, without changing anything.)
Is there a way when using
fileformat=dos to get Vim to keep the Ctrl-Z at EOF? I searched the help brought up by
:help fileformats (the help file is
options.txt) which says:
When "dos" is used, CTRL-Z at the end of a file is ignored. See |file-formats| and |file-read|.
insert.txt) says the same.