Sublime Forum

Slightly different whitespace removal

#1

I’m working on a large code base where whitespace removal is the norm, but they have a slightly different rule than whats used by ‘trim_trailing_white_space_on_save’. They remove whitespace at the end of the line except where auto indent would have put in whitespace. So whitespace on empty lines between methods would retain their whitespace to preserve the same indent level. So if I have autoIndent on in a simple sense /\s+\Z/ , but not /\A\s+\Z/ .

Its a a pretty big problem, because my commits that might have a single line change actually have 30-40 changes (just hiding these with ‘diff -w’ is not enough because the commits include these changes).

Any thoughts on how I could do this? Is there a built in option or do I need to go digging into the existing plugin?

0 Likes

#2

I’m not an expert… but I’d say you will have to make a python script for that.

Here’s an example on how to do something when saving:
github.com/alexnj/SublimeOnSave … veBuild.py

0 Likes

#3

I found an external plugin that does this, except it doesn’t do it on save. It has an option called “trailing_spaces_include_empty_lines”. Now I have two options that don’t get me the full solution. If I could bolt this in to the existing functionality that would rock. :wink:

0 Likes