Godot is creating a new line when i save the project and i want to disable

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By josh__

:bust_in_silhouette: Reply From: Calinou

Godot doesn’t have an option to not add a blank line at the end of scripts. However, it’s considered good practice to add a blank line at the end of files for two reasons:

  • Version control tools like Git (and frontends like GitHub) will complain if your files don’t end with a blank line.
  • If you print out a file which doesn’t end with a blank line with cat, your prompt will appear on the same line as the last line of the file, which looks ugly.

While I like this setting on actual scripts for the mentioned reasons, I do have a counter example: I have a raw .txt file I use for data (credits text) which I display in a label inside a ScrollContainer. Not adding a final line allows me to keep the text as compact as possible so I don’t display the scrollbars unnecessarily. If the text happens to be just fitting right, the blank newline will still cause the scrollbar to appear.

My current workaround is to use text.strip_edges(false, true) to strip any trailing whitespaces/blank lines.

(and of course you can edit the file in an external editor, if you don’t care about the 2 issues mentioned above)

Hyper Sonic | 2023-05-05 13:29