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.


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.