Automatically add a line break at the end of the file

Use case or problem

The default git diff is based on the line break. If there is no line break at the end of the file, when more lines are appended to the file, git diff will treat the last line of the previous version as edited, which is annoying.

Besides, according to POSIX, every text file should end with a \n , or “newline ” character. Break this rule may cause warnings or even errors at some cases.

3 Likes

You can use the obsidian-linter plugin with the line-break-at-document-end option.

Just sharing this for anyone else who finds this topic while searching for a solution.

4 Likes

Old post, but still a problem. I’m using the linter as a work-around, but really this should either be a preference (“setting”) or the behavior should just be changed.

I totally agree with @eponymous_510; this is a basic setting in almost every editor I have ever used.

I think, Obsidian should consider some kind of file linting as a core feature.

The author of Linter is very active and the features of this plugin are numerous, mind blowing and useful. It’s one of the plugins to have in a well maintained favorite list, imo.

I don’t see the Linter plugin as a “workaround”, but meaningful addition, which is definitely missing in Obsidian. A line break at the end of a note is just a tiny, feature you can have as well with Linter.