Add line_ending setting to control line-ending normalization (#54356)
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. --------- Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
This commit is contained in:
1 parent
c97442029a
commit
2a6ee04013
10 files changed
+518
-13
No files matched your search
@@ -1618,6 +1618,56 @@ This setting enables integration with macOS’s native window tabbing feature. W
|
||||
|
||||
`boolean` values
|
||||
|
||||
## Line Ending
|
||||
|
||||
- Description: How line endings should be handled for new files and during format and save. This can be specified on a per-language basis.
|
||||
- Setting: `line_ending`
|
||||
- Default: `detect`
|
||||
|
||||
**Options**
|
||||
|
||||
1. To detect existing line endings and otherwise use the platform default (`lf` on Unix, `crlf` on Windows), set it to `detect`:
|
||||
|
||||
```json [settings]
|
||||
{
|
||||
"line_ending": "detect"
|
||||
}
|
||||
```
|
||||
|
||||
2. To prefer LF (`\n`) for new files and files with no existing line ending, use `prefer_lf`:
|
||||
|
||||
```json [settings]
|
||||
{
|
||||
"line_ending": "prefer_lf"
|
||||
}
|
||||
```
|
||||
|
||||
3. To prefer CRLF (`\r\n`) for new files and files with no existing line ending, use `prefer_crlf`:
|
||||
|
||||
```json [settings]
|
||||
{
|
||||
"line_ending": "prefer_crlf"
|
||||
}
|
||||
```
|
||||
|
||||
4. To enforce LF (`\n`) during format and save, use `enforce_lf`:
|
||||
|
||||
```json [settings]
|
||||
{
|
||||
"line_ending": "enforce_lf"
|
||||
}
|
||||
```
|
||||
|
||||
5. To enforce CRLF (`\r\n`) during format and save, use `enforce_crlf`:
|
||||
|
||||
```json [settings]
|
||||
{
|
||||
"line_ending": "enforce_crlf"
|
||||
}
|
||||
```
|
||||
|
||||
The [`.editorconfig`](https://editorconfig.org) `end_of_line` property overrides this setting and behaves like `enforce_lf` or `enforce_crlf`.
|
||||
|
||||
## Expand Excerpt Lines
|
||||
|
||||
- Description: The default number of lines to expand excerpts in the multibuffer by
|
||||
@@ -2772,6 +2822,7 @@ The following settings can be overridden for each specific language:
|
||||
|
||||
- [`enable_language_server`](#enable-language-server)
|
||||
- [`ensure_final_newline_on_save`](#ensure-final-newline-on-save)
|
||||
- [`line_ending`](#line-ending)
|
||||
- [`format_on_save`](#format-on-save)
|
||||
- [`formatter`](#formatter)
|
||||
- [`hard_tabs`](#hard-tabs)
|
||||
|
||||
Reference in new issue
Block a user