Sublime Forum

How use autocomplete?

#1

When I write ech and press Tab I get echo “string”;
How this customise for myself ?
for example: write ech and press Tab I get echo " ";

0 Likes

#2

You can create a custom snippet for that. :slight_smile:

Go to Tools > Developer > New snippet .. and paste this in :

<snippet>
	<content><![CDATA[
echo "$0";
]]></content>
	<tabTrigger>ech</tabTrigger>
</snippet>

Whatever is between the content tags will be rendered when you press the TAB key, if your cursor is after whatever you defined in the tabTrigger tags.

$0 is used to define where the cursor should be placed once the snippet has been expanded.

0 Likes

#3

I recommend having a look at the:

  • *.sublime-snippet
  • *.sublime-completions

files on sublimehq/Packages on Github. Also take note that some default packages like CSS use Python scripts for auto-completion.

0 Likes

#4

On another note, I would recommend using $1 or ${1:…} in the example above.

You probably want to continue with writing more code and as $0 (where you continue when done) defaults to the end of the snippet, that’s exactly what you need if you want to avoid having to move the cursor like in the example above.

0 Likes