Add to Preferences > Key Bindings - User
:
Auto replace to $this->
after typing $-
// Auto replace to $this-> after typing $-
{ "keys": ["-"], "command": "insert_snippet", "args": {"contents": "this->"}, "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": "selector", "operator": "equal", "operand": "source.php - source.js" }
]
}
Auto replace to $this;
after typing $;
// Auto replace to $this; after typing $;
{ "keys": [";"], "command": "insert_snippet", "args": {"contents": "this;"}, "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": "selector", "operator": "equal", "operand": "source.php - source.js" }
]
},
Automatically adds ->
after typing $this
when in PHP context only.
// Autocompletion of -> after typing $this
{ "keys": ["s"], "command": "insert_snippet", "args": {"contents": "s->"}, "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": "\\$thi$", "match_all": true },
{ "key": "selector", "operator": "equal", "operand": "source.php - source.js" }
]
}
Like PHPStorm: Automatically adds >
after typing $this-
(I don't use this one)
// Autocompletion of > after typing $this-
{ "keys": ["-"], "command": "insert_snippet", "args": {"contents": "->"}, "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": "\\$this$", "match_all": true },
]
}