Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Limiting line length in Atom

I've been trying to get my line length hard limited to 80 characters in Atom. I have found in the setting the "max screen line length" but I cannot set a value there. I've set the soft wrap but this doesn't seem to work either. I checked packages and nothing from a specific language is driving it either. I found the autoflow package but it doesn't give a clear indication of how to drive it to 80 characters. Any advice on how to implement this would be helpful. I understand that 80 characters is the PEP 8 standard and I don't want to start off with issues.

like image 625
theoneinskane Avatar asked Apr 02 '18 18:04

theoneinskane


People also ask

How do you set the ruler in an atom?

Change the ruler position in settings. cson . Toggle with Command-Control-R .


1 Answers

I have found in the setting the "max screen line length" but I cannot set a value there.

The correct setting to set is the Preferred Line Length.
It is part of the same Settings > Editor page where you found Max Screen Line Length.

screenshot for Preferred Line Length

As indicated in the description of Preferred Line Length, you also need to enable the Soft Wrap At Preferred Line Length (still part of the Settings > Editor page). And in the description of Soft Wrap At Preferred Line Length, it says that you also need to enable the main Soft Wrap setting (still part of the Settings > Editor page).

Good thing is they are conveniently placed next to each other.
Enable them both:

screenshot for soft wrap

That takes care of the default Atom editor settings.

Since you mentioned PEP8, make sure you also set the same settings on the pre-included language-python package (Settings > Packages, search for "language-python").

screenshot for language-python

With all those settings, Atom should now automatically wrap long texts into a newline when it exceeds 80 characters. (You can set the character limit to anything actually, ex. 160. Just make sure to set the same Preferred Line Length for both Atom's and language-python's settings.)

like image 104
Gino Mempin Avatar answered Sep 24 '22 20:09

Gino Mempin