An example key binding that does this would be:
{ "keys": ["{"], "command": "insert_snippet",
"args": {"contents": "{\n\t$0\n}"},
"context": [
{ "key": "selector", "operator": "equal", "operand": "source.css" },
],
},
The command insert_snippet
can insert text the same as a snippet could (including variable expansions as you might like); the field $0
sets the place the cursor ends up once the expansion is complete.
The binding makes the command execute any time {
is pressed, so the context
ensures that the only time that this is allowed to happen is inside of a CSS file; otherwise no matter what file you edit, this would always happen.
Depending on your use case, you may find that there are places in a CSS file that you don’t want this to happen, in which case you might need to adjust the context
or add other entries to it to dial in as needed.