Sublime Forum

Trying to understand Tab Auto-completion

#1

Is this normal behavior…

When I type out commands, none of them are recognized by auto-completion unless I already have an occurrence of that same command in my script already. At least, this is true with PowerShell. Could someone tell me if this is normal behavior?

0 Likes

#2

Completions come from a few places:

  • Words that exist in the buffer already
  • sublime-completions files that have predefined lists of trigger words and what they expand to
  • plugins that respond to the on_query_completions event to inject completions (which can theoretically come from anywhere)

In addition there are snippets, but that’s more of a heavyweight thing for injecting full snippets of source code; they’re pretty functionally similar to sublime-completions but a completions file can have many completions in it while sublime-snippet file is a on-off. Typically you would use a sublime-snippet to inject something like a for loop body while you’d use a sublime-completions to provide lists of common functions.

In any case, generally speaking auto-completion popups are usually only sourced from the buffer unless you’ve done something like installed a completions package (or created a file of them yourself) or installed a plugin that does it for you.

The most robust way to do this from a user perspective is the plugin route because it has the power to do complex operations behind the scenes like examine your code to know that bob is a class of a particular type and thus has particular methods, whereas without a plugin completions are provided based on scope and not context.

1 Like

#3

Thanks for explaining. I was hoping that Sublime Text work more like other IDE’s like VSCode where it automatically recognizes all the commands available for the coding language I’m using, like PowerShell. It’s too much hassle for me to try to make my own custom sublime-completions file.

0 Likes

#4

If you install an appropriate addon for your language into Sublime 3 it will do what you are looking for. I use one for Lucee/CFML and it will autocomplete all available tags and even present me with all the available parameters for each tag as is relevant.

0 Likes

#5

That’s exactly what I was hoping for. But unfortunately I can’t find one for PowerShell; which is all I use Sublime Text for. Is there such an addon?

0 Likes