Is there a plugin that will append (php) when you type <?
That would just make my day
Auto complete php tag
It goes to the technical support!
But you could create a snippet
<snippet>
<content><![CDATA[
<?php
]]></content>
<tabTrigger><?</tabTrigger>
<scope>source.php</scope>
</snippet>
Hi All,
Seemed like an excellent suggestion, so I tried it, only to get an XML parsing error.
I found the following after a Google search:
sublimetext.userecho.com/topic/9 … -a-period/
and emended the snippet to the following:
<snippet>
<content><![CDATA[
<?php ${1} ?>
]]></content>
<tabTrigger><?</tabTrigger>
<scope>source.php</scope>
</snippet>
As always, give it a name like “phptag.sublime-snippet,” and save it to your Packages/User directory (or a subfolder - i.e. “/php”).
Hope this saves someone some time! Thanks again for the great suggestion.
Brit
Made a couple auto-complete settings that auto complete PHP tags. It also auto completes the less-than sign, which also comes in handy with HTML tags. Hope it helps.
[code]// Auto-pair less than
{ “keys”: “<”], “command”: “insert_snippet”, “args”: {“contents”: “<$0>”}, “context”:
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|\\}|>|$)", "match_all": true },
{ "key": "preceding_text", "operator": "not_regex_contains", "operand": "<a-zA-Z0-9_]$", "match_all": true },
{ "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.double", "match_all": true }
]
},
{ "keys": "<"], "command": "insert_snippet", "args": {"contents": "<${0:$SELECTION}>"}, "context":
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }
]
},
{ "keys": "<"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^<", "match_all": true }
]
},
{ "keys": "backspace"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Left Right.sublime-macro"}, "context":
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "<$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^>", "match_all": true }
]
},
// Auto-pair PHP percent
{ "keys": "?"], "command": "insert_snippet", "args": {"contents": "?php $0 ?"}, "context":
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|\\}|>|$)", "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "<$", "match_all": true },
{ "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.double", "match_all": true }
]
},
{ "keys": "?"], "command": "insert_snippet", "args": {"contents": "?php ${0:$SELECTION} ?"}, "context":
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }
]
},
{ "keys": "?"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^//?", "match_all": true }
]
},
{ "keys": "backspace"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Left Right.sublime-macro"}, "context":
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "//?$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^//?", "match_all": true }
]
[/code]