Skip to content

Instantly share code, notes, and snippets.

@evoactivity
Last active August 29, 2015 14:22
Show Gist options
  • Save evoactivity/1bc82f822cd3508f64a4 to your computer and use it in GitHub Desktop.
Save evoactivity/1bc82f822cd3508f64a4 to your computer and use it in GitHub Desktop.
Key Bindings to help write well formed css
[
{
"keys": [":"],
"command": "insert",
"args": {"characters": ": "},
"context": [
{
"key": "selector",
"operator":"equal",
"operand":"source.scss"
},
{
"key": "preceding_text",
"operator": "regex_match",
"operand": "^(?<!.|@|#|&)(\\s*)([a-zA-Z0-9\\-_]*)",
"match_all": true
}
]
},
{
"keys": ["{"],
"command": "insert_snippet",
"args": {"contents": " \\{\n\t$0\n\\}\n"},
"context": [
{
"key": "selector",
"operator":"equal",
"operand":"source.scss"
},
{
"key": "preceding_text",
"operator": "regex_contains",
"operand": "[a-zA-Z0-9)]$",
"match_all": true
}
]
}
]
@evoactivity
Copy link
Author

Add these to your user keybindings file in sublime, currently they only work in an .scss file so if you write plain css or use a different preprocessor, change source.scss to be what you need.

@evoactivity
Copy link
Author

Updated to better match when to add a space after :

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment