Learn how to disable the ensure single trailing new line in your Atom Editor.

How to remove trailing whitespace on save in Atom Editor

Why whould I disable the trailing whitespace?

A trailing whitespace is any space or tab after the last non-whitespace character on the line until the next line. Although the spaces are totally harmless for your code, but at the same time there are other programming languages like TCL where a whitespace at the end of the line will mess up the code. Besides it may polute the "peace of writing code" for some developers. Many coding standards require you to eliminate all instances of trailing whitespaces. One reason is of avoiding unnecessary whitespaces (it takes more storage space than necessary according to the amount of data of the file).

Although this behaviour would be ignored for most of the developers, if you are helping an open source project, there may be a contributing rule that may specify that you need explicitly remove the trailing whitespace when making a commit.

Disable trailing whitespace in Atom

If you want to disable the trailing whitespaces, you can do it in 2 ways:

A. The quick and temporary way

You can handle whitespaces with the 6 methods that provide the Whitespace package. When you click on some of the options, the action will be executed once so none of the settings will be stored:

Toolstrip Atom Whitespace Manager

This comes in handy when you only want to make a little modification in some file that doesn't need the trailing whitespace.

B. The temporal way

If you want to store temporary this behaviour, open the settings menu of Atom by pressing CTRL + , or just navigate to File and then Settings. In the settings, switch to the Packages tab and search in the installed packages the whitespace package. This package belongs to the core package of Atom. Once the package appears, click on Settings:

Settings Atom

In this menu, you will have 5 options and their description. You will need to check and uncheck according to your needs:

Atom Settings Trailing Whitespace

Happy coding !

Senior Software Engineer at Software Medico. Interested in programming since he was 14 years old, Carlos is a self-taught programmer and founder and author of most of the articles at Our Code World.