I recently try to adjust to sublime text 3 instead of netbeans which I was using for web development for the last years, I really liked the features in netbeans IDE especially the code templates which is the equivalent to sublime snippets, unfortunately I wasn't able to find the variable from last assignment like in netbeans code templates.
this is code template I am using in netbeans
error_reporting(E_ALL);
ini_set('display_errors', '1');
echo '<pre style="background: black;color: white; font-size:16px; font-wheight:bold; direction:ltr!important;text-align: left;">';
print_r(${VARIABLE variableFromPreviousAssignment default="$variable"});
echo '</pre>';
die();
this is the snippet I am using in sublime text 3
<snippet>
<content><![CDATA[
error_reporting(E_ALL);
ini_set('display_errors', '1');
echo '<pre>';
echo print_r(${1:*});
echo '</pre>';
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>dbg</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.php</scope>
<description>dbug snippet</description>
</snippet>
In simple words what I am looking for is the equivelent in sublime to this in netbeans
(${VARIABLE variableFromPreviousAssignment default="$variable"}
I changed your snippet to the text you had in the Netbeans shortcut:
<snippet>
<content><![CDATA[
error_reporting(E_ALL);
ini_set('display_errors', '1');
echo '<pre style="background:black; color:white; font-size:16px; font-weight:bold; direction:ltr!important; text-align:left;">';
print_r(${1:\$variable});
echo '</pre>';
die();
]]></content>
<tabTrigger>dbg</tabTrigger>
<scope>source.php</scope>
<description>dbug snippet</description>
</snippet>
In a PHP document in Sublime, type dbg
and hit Tab, and the following will appear:
syntax highlighting is Neon
$variable
is highlighted, allowing you to replace it with something of your own choosing.
For more information on snippets, check out the snippet reference.
Unfortunately, there is no way in Sublime to save the value of the last assignment just using a snippet - you'll need a plugin for that. Let me know if that's a feature you really need, and I'll see if I can put something together.