Add line_ending setting to control line-ending normalization - #54356
Merged
smitbarmase merged 4 commits intoApr 22, 2026
Merged
Conversation
melocene
force-pushed
the
add_line_ending_setting
branch
from
April 20, 2026 19:55
7c07285 to
6251fc5
Compare
smitbarmase
force-pushed
the
add_line_ending_setting
branch
from
April 22, 2026 08:41
dd2a34a to
a7defd5
Compare
smitbarmase
approved these changes
Apr 22, 2026
Member
There was a problem hiding this comment.
Thanks, I made few improvements.
- I think that always enforcing these line endings on format and save might not be the best option for everyone, specifically in cases where you might be editing a file from a different operating system and you don't want to change its line endings, while still enforcing the line endings for new files.
- Also, I made a fix for when you create new buffer, it respects your line ending settings.
I introduced two new possibilities for this enum. I think it's better than what VS Code does.
| Enum | New empty file | Existing LF file on format/save | Existing CRLF file on format/save | No-convention file on format/save |
|---|---|---|---|---|
preserve |
Use platform default for the buffer indicator: LF on Unix/macOS/Linux, CRLF on Windows | Stay LF | Stay CRLF | No normalization |
prefer_lf |
Start as LF | Stay LF | Stay CRLF | Become LF |
prefer_crlf |
Start as CRLF | Stay LF | Stay CRLF | Become CRLF |
enforce_lf |
Start as LF | Stay LF | Rewrite to LF | Become LF |
enforce_crlf |
Start as CRLF | Rewrite to CRLF | Stay CRLF | Become CRLF |
Thanks again for working on this! This was a long-awaited feature.
SomeoneToIgnore
approved these changes
Apr 22, 2026
line_ending setting and support .editorconfig `end_of_lineline_ending setting to control line-ending normalization
Contributor
Author
|
@smitbarmase Thanks for the enhancement to this. I also like that it is now in the settings UI too which is great. I initially tried to follow the existing pattern behavior which is why it wasn't as granular. |
This was referenced May 2, 2026
kathbigra
pushed a commit
to kathbigra/zed
that referenced
this pull request
May 10, 2026
…ndustries#54356) Closes zed-industries#49581 Adds a `line_ending` language setting that controls how line endings are handled for new files and during format/save: - `detect` (default) — detects existing line endings; new files use the platform default - `prefer_lf` / `prefer_crlf` — sets LF or CRLF for new files and files with no existing convention, while preserving existing files - `enforce_lf` / `enforce_crlf` — normalizes all line endings to LF or CRLF on every format/save The setting can be configured globally, per-language, or via `.editorconfig`'s `end_of_line` property (which maps to `enforce_lf` / `enforce_crlf`). Release Notes: - Added `line_ending` setting to control how line endings are handled for new files and normalized on save. - Added support for `.editorconfig` `end_of_line` property to enforce line endings. --------- Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
Zenor27
pushed a commit
to Zenor27/zed
that referenced
this pull request
Jul 4, 2026
…ndustries#54356) Closes zed-industries#49581 Adds a `line_ending` language setting that controls how line endings are handled for new files and during format/save: - `detect` (default) — detects existing line endings; new files use the platform default - `prefer_lf` / `prefer_crlf` — sets LF or CRLF for new files and files with no existing convention, while preserving existing files - `enforce_lf` / `enforce_crlf` — normalizes all line endings to LF or CRLF on every format/save The setting can be configured globally, per-language, or via `.editorconfig`'s `end_of_line` property (which maps to `enforce_lf` / `enforce_crlf`). Release Notes: - Added `line_ending` setting to control how line endings are handled for new files and normalized on save. - Added support for `.editorconfig` `end_of_line` property to enforce line endings. --------- Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
jonx
pushed a commit
to jonx/zed-aros
that referenced
this pull request
Jul 17, 2026
…ndustries#54356) Closes zed-industries#49581 Adds a `line_ending` language setting that controls how line endings are handled for new files and during format/save: - `detect` (default) — detects existing line endings; new files use the platform default - `prefer_lf` / `prefer_crlf` — sets LF or CRLF for new files and files with no existing convention, while preserving existing files - `enforce_lf` / `enforce_crlf` — normalizes all line endings to LF or CRLF on every format/save The setting can be configured globally, per-language, or via `.editorconfig`'s `end_of_line` property (which maps to `enforce_lf` / `enforce_crlf`). Release Notes: - Added `line_ending` setting to control how line endings are handled for new files and normalized on save. - Added support for `.editorconfig` `end_of_line` property to enforce line endings. --------- Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
jolutz
pushed a commit
to jolutz/zed
that referenced
this pull request
Aug 8, 2026
…ndustries#54356) Closes zed-industries#49581 Adds a `line_ending` language setting that controls how line endings are handled for new files and during format/save: - `detect` (default) — detects existing line endings; new files use the platform default - `prefer_lf` / `prefer_crlf` — sets LF or CRLF for new files and files with no existing convention, while preserving existing files - `enforce_lf` / `enforce_crlf` — normalizes all line endings to LF or CRLF on every format/save The setting can be configured globally, per-language, or via `.editorconfig`'s `end_of_line` property (which maps to `enforce_lf` / `enforce_crlf`). Release Notes: - Added `line_ending` setting to control how line endings are handled for new files and normalized on save. - Added support for `.editorconfig` `end_of_line` property to enforce line endings. --------- Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #49581
Adds a
line_endinglanguage setting that controls how line endings are handled for new files and during format/save:detect(default) — detects existing line endings; new files use the platform defaultprefer_lf/prefer_crlf— sets LF or CRLF for new files and files with no existing convention, while preserving existing filesenforce_lf/enforce_crlf— normalizes all line endings to LF or CRLF on every format/saveThe setting can be configured globally, per-language, or via
.editorconfig'send_of_lineproperty (which maps toenforce_lf/enforce_crlf).Release Notes:
line_endingsetting to control how line endings are handled for new files and normalized on save..editorconfigend_of_lineproperty to enforce line endings.