moonlord wrote: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.
Glad you found heaven! when it comes to text editors lol. Anyways,
moonlord wrote: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).
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
http://www.sublimetextwiki.com/pages/Ed ... ences.htmlmoonlord wrote:Also when i'm between <?php ?> tags i can't use html snippets.
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.
- Code: Select all
<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:
- Code: Select all
<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
<binding key="a,tab" command="insertSnippet 'Packages/HTML/a.sublime-snippet'">
<context name="selector" value="source.php, text.html - meta.tag - source, meta.scope.between-tag-pair.html"/>
</binding>
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.