atom / whitespace

Atom whitespace package
MIT License
94 stars 67 forks source link

Documentation is too sparse #194

Open max-rocket-internet opened 4 years ago

max-rocket-internet commented 4 years ago

I'm here because I need to stop Atom from removing trailing whitespace and blank lines containing spaces for a particular Python project.

I just want to know how to:

  1. Make config apply within a single project only
  2. Target Python language files only

It seems there is only a very brief project README and no other docs or examples?

wjandrea commented 2 years ago

Targeting a specific language is already covered in the README.

For per-project config, try Atomic Management. It works for my case where I need to disable ensureSingleTrailingNewline for all languages in a project. Your .atom/config.cson would look something like this:

'.source.python':
  whitespace:
    removeTrailingWhitespace: false

By the way, maybe you already know this, but PEP 8 recommends avoiding trailing whitespace entirely in Python, including lines containing only whitespace:

Avoid trailing whitespace anywhere. Because it's usually invisible, it can be confusing: e.g. a backslash followed by a space and a newline does not count as a line continuation marker. Some editors don't preserve it and many projects (like CPython itself) have pre-commit hooks that reject it.

Hypothetically, if the trailing whitespace is inside triple-quoted strings, as a workaround you could replace it with escapes, like \x20 for a space.

wjandrea commented 2 years ago

@max-rocket-internet FYI, I updated my above comment cause I found a solution and my original suggestion about a keymap was bogus.