Sublime Forum

Can variables be used in code snippets?

#1

For example, I want to press Tab after ABC, it will automatically become ABC = ‘’;
But ABC is not fixed, it may be acoo, y001, var001 …
Is it possible to implement such a variable code snippet?

99-
Just to give an example.
The actual situation is definitely more complicated than this.

0 Likes

#2

${1:varName} = ${2:value}
Is how I would do it.

0 Likes

#3

seems more like you want a keybinding to execute a custom completion action (using a Python plugin) than a static snippet, though what you are asking for is possible without Python if you were to select the text before invoking the snippet

0 Likes