Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call setl [no]endofline using insert_final_newline #197

Closed
wants to merge 1 commit into from
Closed

Call setl [no]endofline using insert_final_newline #197

wants to merge 1 commit into from

Conversation

TysonAndre
Copy link

@TysonAndre TysonAndre commented Oct 23, 2022

When I use :r testname.out to read the lines of a file (where testname.out has no trailing newline)
into the end of a file or replace the end of a file (e.g. testname.phpt with --EXPECT-- or --OUTPUT-- sections), and the binary option was set
(I think I set that years ago for php files, for editing tests containing binary non-utf8 data? as a workaround to avoid diff noise when changing newlines in files in existing projects with no coding standards. This predated vim's support for fixendofline.),
the resulting file has no newline when saving without setl endofline.

EDIT: In the vast majority of use cases, enabling endofline for modern vim and overriding the binary setting seems like a mistake (e.g. most users would be opening binary file formats). I had au FileType php setlocal binary set years ago and should remove that.

vim help text:
'endofline' 'eol'	boolean	(default on)
			local to buffer
	When writing a file and this option is off and the 'binary' option
	is on, or 'fixeol' option is off, no <EOL> will be written for the
	last line in the file.  This option is automatically set or reset when
	starting to edit a new file, depending on whether file has an <EOL>
	for the last line in the file.  Normally you don't have to set or
	reset this option.
	When 'binary' is off and 'fixeol' is on the value is not used when
	writing the file.  When 'binary' is on or 'fixeol' is off it is used
	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.

(This is checked outside of exists('+fixendofline'), to also work in older vim releases)

Alternative to #174

When I use `:r testname.out` to read the lines of a file
(where testname.out has no trailing newline)
into the end of a file or replace the end of a file
(e.g. testname.phpt with `--EXPECT--` or `--OUTPUT--` sections),
the resulting file has no newline when saving without `setl endofline`.

(This is checked outside of exists('+fixendofline'), to also work in older vim releases)
@TysonAndre TysonAndre closed this Oct 23, 2022
@TysonAndre TysonAndre deleted the patch-1 branch October 23, 2022 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant