Create new plugin from Tools -> Developer -> New Plugin...
and save the following code as PasteInPhpEchoCommand.py
.
import sublime
import sublime_plugin
class PasteInPhpEchoCommand(sublime_plugin.TextCommand):
def run(self, edit):
text_src = sublime.get_clipboard().strip("\r\n")
if not text_src:
return
text_quoted = "echo <<<'HTML'\n{code}\nHTML;\n".format(code=text_src)
self._doPaste(edit, text_quoted)
def _doPaste(self, edit, text):
for sel in self.view.sel():
if len(sel) != 0:
self.view.erase(edit, sel)
self.view.insert(edit, sel.begin(), text)
Add a keybinding for the command:
{
"keys": ["ctrl+alt+x"], // whatever keybinding you like
"command": "paste_in_php_echo",
"context": [
// only work in PHP scope
{
"key": "selector",
"operator": "equal",
"operand": "embedding.php | source.php",
},
],
}