diff --git a/internal/config/settings.go b/internal/config/settings.go index 72e998f1..05a9f8a4 100644 --- a/internal/config/settings.go +++ b/internal/config/settings.go @@ -8,6 +8,7 @@ import ( "os" "path/filepath" "reflect" + "runtime" "strconv" "strings" @@ -284,7 +285,7 @@ var defaultCommonSettings = map[string]interface{}{ "encoding": "utf-8", "eofnewline": true, "fastdirty": false, - "fileformat": "unix", + "fileformat": defaultFileFormat(), "filetype": "unknown", "hlsearch": false, "incsearch": true, @@ -319,6 +320,13 @@ var defaultCommonSettings = map[string]interface{}{ "wordwrap": false, } +func defaultFileFormat() string { + if runtime.GOOS == "windows" { + return "dos" + } + return "unix" +} + func GetInfoBarOffset() int { offset := 0 if GetGlobalOption("infobar").(bool) { diff --git a/runtime/help/options.md b/runtime/help/options.md index 3170dc4c..75e877e8 100644 --- a/runtime/help/options.md +++ b/runtime/help/options.md @@ -157,7 +157,7 @@ Here are the available options: an effect if the file is empty/newly created, because otherwise the fileformat will be automatically detected from the existing line endings. - default value: `unix` + default value: `unix` on Unix systems, `dos` on Windows * `filetype`: sets the filetype for the current buffer. Set this option to `off` to completely disable filetype detection.