How to prevent Godot Editor add new blank line at the end of file

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

I use Godot Editor 3.2 to edit an existing project. But it auto add a blank line at the end of file. How to I disable this behavior?

:bust_in_silhouette: Reply From: jgodfrey

There’s not really a blank line added to your document. If you look at the script file in a hex editor, you’ll see that it simply ends with an OA character - which is a newline.

So, really, every line in the file (including the last line) ends with a newline character. I assume the editor just chooses to render that case visually with a new line, but it doesn’t actually exist in the file until you add content to it.

If you look at your file in (for example) VS Code, it’ll render the same way (with a visual blank at the end).

Moreover, it’s considered good practice to end all files with a newline (as per the POSIX specification).

Calinou | 2020-03-10 12:52

See my comment on Godot is creating a new line when i save the project and i want to disable - Archive - Godot Forum for the case of loading text as a resource, where it can bring a visual difference, and a workaround)

Hyper Sonic | 2023-05-05 13:33