de-jcup / eclipse-yaml-editor

Eclipse YAML editor
https://marketplace.eclipse.org/content/yaml-editor
Apache License 2.0
35 stars 10 forks source link

Ability to remove trailing whitespace #112

Closed pwatt01 closed 1 year ago

pwatt01 commented 2 years ago

It would very very useful if we coudl please have an option in the formator preferences to remove trailing whitespace on save.

de-jcup commented 2 years ago

Hello @pwatt01 ,

please add some sample code example with "before" and "after" save action so it is clear what is meant.

Currently the formatting is done by snake yaml parser. Only comment restoring is done additionally by the plugin (because the parser does not provide this). It could be possible to implement an addition here, but I have not much time at the moment and so it must be very clear what you want before I (or anybody else) can implement the feature.

pwatt01 commented 2 years ago

Thanks for replying. It is kind of hard to show this as the review removes the whitespace automatically, so i have added an image on pasteboard to desccribe what I am after. If not, the below might make sense

https://pasteboard.co/U5usx7PfKR89.png Before:

doe: "a deer, a female deer"\s\s\s\s\t\s\s\t\t\t\
ray: "a drop of golden sun"\s\s\s\s\
pi: 3.14159\s\s\s\s\
xmas: true\t
french-hens: 3\s\s
calling-birds:\s\s\s\s\s\s\t\t\t\t\t\s\s\s\s\t\t\t
 - huey\t\t\t\t\t
 - dewe\s\s\s\s\\t\t\t\t\t\t

After

doe: "a deer, a female deer"
ray: "a drop of golden sun"
pi: 3.14159
xmas: true
french-hens: 3
calling-birds:
 - huey
 - deweyy
de-jcup commented 2 years ago

Hm.. I tested and the trailing of whitespaces at the end does always work! Only when it comes to tab characters (which are illegal in Yaml) there is a problem with the snake yaml formatter.

Instead of the "remove trailing whitespaces" a "auto convert tab characters" inside the formatter would make more sense - it could use the setup inside the preferences.

Please give me feedback if the "auto convert tab characters" is your wanted feature .

de-jcup commented 1 year ago

The image is no longer available and there was no response to my last question - so I close the issue.