0

Ok... I guess it may sound stupid or lazy, but I'm doing a lot of CSS lately, and that simple fact of having to type "px" right after every single width or height or margin and so on is drivin' me nuts.

I usually 'refine' pixels' values in Firebug so I often have to retype the values in the original document.

Now... It would be great if a string like "125px" would behave like a "120%" one, since double-clicking on "120%" only selects "120". But AFAIK that's not doable.
(Oh, PLEASE, tell me I'm wrong)!

So I've been triyn' to make a "snippet" meant to be triggered under the css scope which would allow me to only type the value and then press "Tab" and let TM add those "px" part.

The "Activation" field, in the Bundle Editor, should look like:

[Tab trigger] \d or [0-9] (regex for "any number")

and the "Scope selector" all or some of the following:

source.css meta.property-list.css meta.property-value.css constant.numeric.css keyword.other.unit.css

Useless to say, it doesn't work this way. (Hitting "Tab" key only returns a… "Tab" (\t) )
So, back to the topic: is it possible to Tab-trigger a snippet by a regex, or there is something different I can do which I don't know or I just didn't think of?

TIA!

cià
ale

ALFABreezE
  • 57
  • 6

1 Answers1

0

Don't know if this helps you or not but I do basic HTML snippet tab triggers like this:

So when I'm working on an HTML email for example, if I type tspace followed by tab it outputs the two nested tables and moves the cursor to enter a value where $1 is, a second tab moves the cursor to $2 to enter a value there.

enter image description here

davidcondrey
  • 34,416
  • 17
  • 114
  • 136
  • Looks like I've managed to get it workin' by using the ${TM_SELECTED_TEXT} variable. So, in the "Edit Snippet" field I wrote: `${TM_SELECTED_TEXT}${1:px}$0` while for the "Activation:" I've switched to "Key Equivalent" and choose the "Enter" key. As for the "Scope Selector" looks like `source.css` or `meta.property-value.css` work the same. I'm not satisfied with the result, though, 'cause if I keep on hittin' the "Enter" key, it keeps adding "pxpxpxpxpx..." :) I think it'd need some regex, or a better defined scope, or both... Oh well... cià ale – ALFABreezE May 27 '14 at 16:54