Sublime Forum

Bug?

#1

Hello everyone. For the start i’d like to say that i was impressed when i first started this texteditor. I’ve tested many editors including, e, intype, notepad++ and i think Sublime its on top of them.
Still, i have one question: i’ve noticed that there are php snippets but i can’t find the php language on the bottom right of the screen (where you specify language for a specific file). Php it’s missing from there. Is it a bug?

Keep up the good job.

later edit: Also when i’m between <?php ?> tags i can’t use html snippets. why?

0 Likes

#2

Glad you found heaven! when it comes to text editors lol. Anyways,

Author (Jon) is aware of this “bug”, for now just put it in HTML and do your <?php ?>
Other alternative (and this is what I do) install EditPreferences package then press “ctrl+alt+shift+n” it will allow you to select the file type that you want, this one does have “PHP” on it
sublimetextwiki.com/pages/Ed … ences.html

Because of the scope.
Snippets in sublime-snippet files just take care of the snippets functionality like what is it that this snippet is supposed to do.
Then you have sublime-keymap files, in here is where keybindings take place, this is where you bind your tab triggers and you define contexts like scope.

NOTE: sublime-snippet files now allows you to define, tab trigger, scope and description within the file, this is new tho but you can see by yourself how they work if you visit some PHP snippets.

<snippet> <content><![CDATA[\$GLOBALS['${1:variable}']${2: = }${3:something}${4:;}$0]]></content> <tabTrigger>globals</tabTrigger> <scope>source.php</scope> <description>$GLOBALS'…']</description> </snippet>


If you go to the HTML.sublime-keymap file, you will see HTML snippets defined there, example:

<binding key="a,tab" command="insertSnippet 'Packages/HTML/a.sublime-snippet'"> <context name="selector" value="text.html - meta.tag - source, meta.scope.between-tag-pair.html"/> </binding>
If you see context name=“selector” (really selector = scope)
in the value you put the scope the snippet is supposed to work on, if you want your HTML snippets to work for PHP too, just add source.php to the scope (selector) so to make above snippet work we would do

[quote]

[/quote]

You comma separate more than one scope.
You can see the current scope by pressing ctrl+alt+p, it will be shown to you in status bar.
Scopes are very convenient, they allow you to target snippets specifically for pretty much everything you want, like let’s say you want to do a snippet that when you are in comments it does something, and you want that same snippets to do something else when you are in strings, well with scopes you can =]
NOTE: scopes (selector) are not limited to snippets only, you can run macros, command or scripts when you are in X scope if you wish to do so.

0 Likes

#3

Well, thanks for your time. That was a really complex answer. I appreciate it.

P.S. Now i understand what scopes are for :smiley:

0 Likes

#4

[quote=“moonlord”]Well, thanks for your time. That was a really complex answer. I appreciate it.

P.S. Now i understand what scopes are for :smiley:[/quote]

Your welcome. :smiley:

Sublime documentation is lacking a little bit but I have heard that is on the oven cooking :smile:

0 Likes

#5

Another thing: Unindent (shift+tab) it’s not working for me. Indent(tab) it’s working.

0 Likes

#6

Yes, this way it works. It just i was used to click at the end of the line and use shift+tab or select the line with the mouse and press shift+tab

0 Likes