Skip to content

Add line_ending setting to control line-ending normalization - #54356

Merged
smitbarmase merged 4 commits into
zed-industries:mainfrom
melocene:add_line_ending_setting
Apr 22, 2026
Merged

smitbarmase merged 4 commits into
zed-industries:mainfrom
melocene:add_line_ending_setting

Conversation

@melocene

@melocene melocene commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Closes #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.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Apr 20, 2026
@zed-community-bot zed-community-bot Bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Apr 20, 2026
@melocene
melocene force-pushed the add_line_ending_setting branch from 7c07285 to 6251fc5 Compare April 20, 2026 19:55
@smitbarmase smitbarmase self-assigned this Apr 20, 2026
@smitbarmase
smitbarmase force-pushed the add_line_ending_setting branch from dd2a34a to a7defd5 Compare April 22, 2026 08:41

@smitbarmase smitbarmase left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@smitbarmase smitbarmase changed the title Add line_ending setting and support .editorconfig `end_of_line Add line_ending setting to control line-ending normalization Apr 22, 2026
@melocene

Copy link
Copy Markdown
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.

@smitbarmase
smitbarmase merged commit 2a6ee04 into zed-industries:main Apr 22, 2026
32 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zed does not respect .editorconfig's end_of_line setting

3 participants