code icon indicating copy to clipboard operation
code copied to clipboard

Extension: Avoid stripping trailing whitespace for certain file types - even though the extension is active

Open marbetschar opened this issue 5 years ago • 4 comments

Prerequisites

  • [x] I have searched open and closed issues for duplicates.

Feature

There are certain file types where stripping whitespace on save does not make sense or might even change the way the file is handled. Examples are *.py or *.yml

So the plugin should not alter the file on save even though it is activated. It might be beneficial to allow the user to configure the file endings which should be ignored for trailing whitespace.

Meanwhile it is certainly possible to deactivate the plugin manually for these file types - but its a bit cumbersome, since I always forget it at the first attempt.

marbetschar avatar Sep 08 '20 17:09 marbetschar

Could you give a specific example of where removing trailing whitespace is problematic?

jeremypw avatar Sep 08 '20 18:09 jeremypw

In Markdown, two spaces at the end of a line is a line break, so stripping trailing spaces would condense paragraphs that aren't supposed to be.

mcclurgm avatar Nov 15 '20 16:11 mcclurgm

@jeremypw removing whitespace is also problematic in *.yml files; e.g. in a case like this:

  - key: "#gist"
    val: |-
             ## Test Title
             
             Here goes the content

In this case we really want to keep the intendation, because otherwise it seems the val gets messed up (no longer two linebreaks, just a space). Not 100% sure why, maybe due to the same reason @mcclurgm mentioned.

marbetschar avatar Nov 25 '20 13:11 marbetschar

@marbetschar - OK, fair enough.

jeremypw avatar Nov 25 '20 16:11 jeremypw