SublimeText / TrailingSpaces

Highlight trailing spaces and delete them in a flash.
MIT License
897 stars 94 forks source link

Unable to prevent trim on Markdown files (pull #47 not working?) #78

Closed stefanosc closed 4 years ago

stefanosc commented 10 years ago

Hello and thank you for your work on this nifty plugin.

I am trying to exclude markdown files from the trim trailing spaces. I tried to set it up in my preferences in many ways but can't get it to work, not matter what I do it trims the spaces in markdown. Here are my Sublime preferences Am I missing something or there is something not working? Thank you very much!

zanona commented 9 years ago

Same here with Diff. When changing a syntax to Diff and saving the file it still strips out the trailing space?

kwyn commented 9 years ago

I have the same problem. I'd like to ignore jade files but including "jade" or ".jade" in the ignore command doesn't work.

robsonsobral commented 8 years ago

Isn't possible to create an RegEx which excludes \s{2}$? I tried to code it, but I don't have enough expertise for it.

misterbrownlee commented 7 years ago

Wow... issue zombie which maybe is appropriate for Halloween.

I believe this can be marked as 'resolved' because there is a setting for ignoring specific files BASED ON SYNTAX and it works if you have things configured right.

The mistake people are maybe making is putting the extension in the plugin configuration, which isn't going to work. Per the docs, it's expecting the syntax ST is using to format in the UI, not the file extension. So you would need to enter 'Markdown' or 'Diff', NOT '.md' or '.diff' or whatever.

Another mistake people are maybe making is having trim_automatic_white_space turned on globally for ST, which I think would clobber any settings for this plugin. I'm not going to bother testing that, but it's a good guess, right? 😀

If it helps, have this config for global settings:

// in ~/Library/Application Support/Sublime Text 3/Packages/User/Preferences.sublime-settings
...
  "trim_automatic_white_space": false,
...

And this for TrailingSpaces

// ~/Library/Application Support/Sublime Text 3/Packages/User/trailing_spaces.sublime-settings
{
  "trailing_spaces_modified_lines_only": true,
  "trailing_spaces_trim_on_save": true,
  "trailing_spaces_syntax_ignore": ["Markdown"]
}

And it works.

I'm using ST3 build 3126 if that matter.

HTH, Happy Halloween! 👻

akrabat commented 7 years ago

Using just "Markdown" didn't work for me. I had to set it like this:

{
    "trailing_spaces_modified_lines_only": true,
    "trailing_spaces_trim_on_save": true,
    "trailing_spaces_syntax_ignore": ["Packages/Markdown/Markdown.sublime-syntax"]
}

in ~/Library/Application Support/Sublime Text 3/Packages/User/trailing_spaces.sublime-settings

ozanmuyes commented 7 years ago

Markdown worked for me (on Debian Jessie) as @misterbrownlee said. Also note it seems like it is a necessity to restart ST after the configuration change.

tjconcept commented 6 years ago

If someone is wondering how to get this behaviour with the built-in white space trimmer:

In the general settings file ("Preferences" → "Settings"): "trim_trailing_white_space_on_save": true

Open a patch or switch to the Diff syntax, go to "Preferences" → "Settings - Syntax Specific": "trim_trailing_white_space_on_save": false

I'm on MacOS 10.13.4, Sublime Text 3.1.1 Build 3176.

rchl commented 4 years ago

Configuration options for this package need to be set in package-specific settings (Preferences: Trailing Spaces Settings from command palette). They won't work from global preferences or syntax settings (latter will probably be supported eventually).

Closing this as "user error".