Search code examples
textmatetextmate2

scopeAttributes with multiple values


I'm using the Strip-Whitespace-On-Save & Ensure-Newline-At-The-EOF bundles.

Now there are some files for which I don't want anything to automatically happen (I'm testing with CSV, since it's sooo delicate).

I've tried the following .tm_properties settings :

[*.csv]
scopeAttributes = attr.keep-whitespace
scopeAttributes = attr.do-not-ensure-new-line

which results in the following attributes (⌃⇧P) :

attr.do-not-ensure-new-line

ie. the first attribute disappears. Reversing the order (expectedly) makes the other attribute show up. Having two separate [*.csv] sections, results in the same behavior.

Using those settings :

[*.csv]
scopeAttributes = attr.keep-whitespace,attr.do-not-ensure-new-line

results in a attr.keep-whitespace,attr.do-not-ensure-new-line attribute, which the bundles ignore. Adding curly braces around the scopeAttributes value just makes the curly braces show up (eg. {attr.keep-whitespace,attr.do-not-ensure-new-line}).

I've looked around in docs and gists, but every example I've seen only does single attributes at a time.


Solution

  • You need to specify both scopes separated by a space (and then you need to quote the whole thing, to make sure it’s parsed correctly):

    [*.csv]
    scopeAttributes = "attr.keep-whitespace attr.do-not-ensure-new-line"