diff --git a/internal/buffer/save.go b/internal/buffer/save.go index 74b890eb..6f07ea6c 100644 --- a/internal/buffer/save.go +++ b/internal/buffer/save.go @@ -112,7 +112,7 @@ func (b *Buffer) saveToFile(filename string, withSudo bool) error { if b.Settings["eofnewline"].(bool) { end := b.End() if b.RuneAt(Loc{end.X, end.Y}) != '\n' { - b.Insert(end, "\n") + b.insert(end, []byte{'\n'}) } } diff --git a/internal/config/settings.go b/internal/config/settings.go index 81c431d8..5f5694e2 100644 --- a/internal/config/settings.go +++ b/internal/config/settings.go @@ -191,7 +191,7 @@ var defaultCommonSettings = map[string]interface{}{ "cursorline": true, "diffgutter": false, "encoding": "utf-8", - "eofnewline": false, + "eofnewline": true, "fastdirty": false, "fileformat": "unix", "filetype": "unknown", diff --git a/runtime/help/options.md b/runtime/help/options.md index 709bd5da..8b118380 100644 --- a/runtime/help/options.md +++ b/runtime/help/options.md @@ -85,9 +85,10 @@ Here are the available options: default value: `utf-8` -* `eofnewline`: micro will automatically add a newline to the file. +* `eofnewline`: micro will automatically add a newline to the end of the + file if one does not exist. - default value: `false` + default value: `true` * `fastdirty`: this determines what kind of algorithm micro uses to determine if a buffer is modified or not. When `fastdirty` is on, micro just uses a