Sublime Forum

Snippets problem

#1

Hi Sublime team,

Am i the only one to experience Snippet problems ?
Snippets are pretty much unusable because new snippets are trigged even when I am in previous Tab Stop editable zone.

To reproduce it, create a new document, choose the HTML package, type “html” then tab.

<html>
<head>
	<title>*TAB STOP*</title>
</head>
<body>

</body>
</html>

Now, in the title area, type a title than ends with a ‘u’ (ex. “Tutu”) and press Tab to jump to the next Tab Stop… It does’nt jump but add a new snippet to the title.

<title>Tut<u></u></title>

Worse, I made my own img tag snippet.

<img src="$1" alt="$2" />

When I type “mypicture.jpg” as an image src and press tab to jump to the 2d spot, Sublime gives me that:

<img src="<mypicture class="jpg"></mypicture>" title="" />

Impossible to type an image src.

I think the most obvious solution would be to disabled trigger in Tab Stops.
Is there a bug or is there something I don’t understand ?

Thanks in advance for your reply.

0 Likes

How to modify or remove snippet?
#2

I’ve also been having a similar issue. I tried your fix but it also disabled the snippet in tags which severely reduces the usefulness of the snippet. For example, you can’t insert the snippet in any html tag such as in a paragraph or div tag. I assume that’s what ‘meta.scope.between-tag-pair.html’ was meant to fix but it doesn’t seem to. Is there a scope that would just simply disable the snippet in a tag attribute? because that would easily solve the problem.

Also is there any sort of functionality similar to TextMates ctrl + shift + p that shows the scopes of what’s selected?

Thanks.

0 Likes

#3

ctrl+alt+p
Watch the status bar

0 Likes

#4

[quote=“EJ12N”]ctrl+alt+p
Watch the status bar[/quote]

Awesome! Thanks.

EDIT After some playing around with this there are some really odd things going on.

[code]

Some Title

Some text to test.

	Some text to test.
</div>

Some text to test.
[/code]

Take the above situation. I have an snippet with the scope of ‘text.html - meta.tag’. Now this stops it from being triggered in tag attributes but stops it in some odd places. For instance, it won’t trigger in the

tag but it will trigger in the

and tags. Now I used that mentioned command on all ‘Some text to test.’ and they all came back the exact same as ‘text.html.basic’. So why will it trigger in the and
tags but not the

tag?

0 Likes

#5

That did the trick. Thanks a bunch. Also real quick, what does that last ‘- source’ actually do?

0 Likes

#6

The ‘- source’ portion prevents it from matching against any names with source in them: in this case, it disables the HTML snippets within tags.

0 Likes

#7

[quote=“sublimator”]TBH I’m not sure :smile: But I’m not arrogant enough to assume it does nothing

EDIT:

Just to be clear, I wasn’t calling you arrogant in some roundabout way or anything. I just don’t know and was too lazy to check. The best resource for information about scoping is the TextMate manual. If you get a answer please post back. Cheers.[/quote]

Haha, nah I know what you meant.

I wish there was a better resource for scopes. The best I’ve found is this in the TextMate manual but it still leaves some things out. A giant list of all the difference selectors would be nice.

0 Likes

#8

Ah cool. Thanks a bunch.

0 Likes

#9

These issues are somewhat fixed in 20091002. HTML snippets have better scopes assigned by default now. The first issue, of typing a string with a tab trigger suffix and pressing tab, is still there.

0 Likes