Reputation: 20163
I am just starting with Sublime Text 3, and I can't get my first autocomplete file working. I'm also not understanding how to make a scope work for - ANY file type, or - MULTIPLE TYPES of files, such as either Java or JavaScript
Following these instructions, I've created a file named
C:\Users\jeffy\AppData\Roaming\Sublime Text 3\Packages\User\sublime_specific.sublime-completions
with this text
{
"scope": "text.plain",
"completions":
[
{ "trigger": "sublime", "contents": "sublime.log_commands(${1:True})" },
{ "trigger": "sublime", "contents": "sublime.log_input(${1:True})" },
{ "trigger": "view", "contents": "view.run_command('$1')" },
]
}
I then open a new document, save it as temp.txt, and then start typing "sublime" or "view". But nothing pops up at any point, even if I hit the "auto_complete" key-command.
How can I get this autocomplete working, and how can I set the scope, so it works in either any type of file, or for either (for example) Java or JavaScript files?
Thanks.
Upvotes: 1
Views: 103
Reputation: 102872
You need to remove the final comma ,
after the "view"
line, as it's not valid JSON. With it there, it results in a parse error (which you should see if you check the console) and the completions are not read into memory.
As for scoping, identifying multiple scopes is quite straightforward. If you want a completion to work everywhere, just set
"scope": "source, text"
For multiple languages, use
"scope": "source.java, source.javascript"
You can define sub-scopes by separating them with spaces
"scope": "source.python meta.structure.list"
And you can remove scopes by using the -
operator
"scope": "source - comment"
Upvotes: 2