Reputation: 940
I'd like to create a package containing a series of snippets that incorporate user-definable variables. For example, I'd like the user to be able to provide a value for a variable called HOSTNAME
and have the snippets include that user's value.
The Sublime Text Unofficial Documentation explains:
Snippets have access to contextual information in the form of environment variables. Sublime Text automatically sets the values of the variables listed below.
You can also add your own variables to provide extra information. These custom variables are defined in .sublime-options files.
I've had no luck finding any information on the syntax for a .sublime-options
file, however, and Sublime does not seem to try to read a file with that extension when I save it anywhere under the Packages
directory. Is this a typo?
Using a .tmPreferences
file seems to do what I'm looking for. Is this the only method of getting user-defined values into a snippet? Is it possible to use a .sublime-settings
file?
Upvotes: 4
Views: 1196
Reputation: 12197
The .sublime-options
, actually, is the .sublime-settings
. .sublime-options
were the ST1 files and the docs got outdated, BUT you use the wrong link, you should always check and switch in the sidebar on the left to your version - ST2, ST3.
And to answer your question, you need to put the variables in .tmPreferences
as may be seen here
Upvotes: 5