Sublime Forum

Autocomplete "this" in PHP files

#1

Writing $this-> in PHP files can be a bit tedious, as it requires pressing [Shift]+$ and then [Shift]+>.

It would be great if Sublime Text suggested $this-> in the autocompletion list once we type this . Pressing [Tab] would then replace this with $this-> .

This idea is somehow similar to the function that replaces php with <?php ?> after pressing [Tab]

0 Likes

#2

You can create a snippet to do this.

<snippet>
	<content><![CDATA[\$this->]]></content>
	<tabTrigger>this</tabTrigger>
	<scope>source.php</scope>
</snippet>
2 Likes

#3

Thanks, that is very good to know, I just tested and it works well!

But still, I suggest adding this in standard Sublime Text as PHP is a popular language and classes are full of $this.

0 Likes

#4

feel free to make a Pull Request. Note that there is a this snippet, but it only triggers when in the HTML code, not the PHP code…

0 Likes