Skip to content

Instantly share code, notes, and snippets.

@gillibrand
Last active December 16, 2015 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gillibrand/5423968 to your computer and use it in GitHub Desktop.
Save gillibrand/5423968 to your computer and use it in GitHub Desktop.
Sublime Text key bindings to make auto-paired characters more useful. Lets you can `tab` out of a string (and `[]` and `()`) if the cursor is before the closing character. Only used these for a few hours... may need some tweaking.
// Move out of common paired characters () and [] with `Tab`
{
"keys": ["tab"],
"command": "move",
"args": {"by": "characters", "forward": true},
"context":
[
// Check if next char matches (followed by anything)
{ "key": "following_text", "operator": "regex_match", "operand": "(:?`|\\)|\\]).*", "match_all": true },
// ...and that there is a paid character before it on the same
// line. This lets you `tab` to Indent at lines with single ]s
// still, like in a JSOn file
{ "key": "preceding_text", "operator": "regex_contains", "operand": "(:?`|\\(|\\[)", "match_all": true }
]
},
// Move out of single and double quotes with `Tab`
{
"keys": ["tab"],
"command": "move",
"args": {"by": "characters", "forward": true},
"context":
[
{ "key": "following_text", "operator": "regex_match", "operand": "(?:\"|').*", "match_all": true },
// Wanted to check if we're inside a string scope here, but that
// seems to match even before an opening quote. This doesn't
// really work yet
{ "key": "selector", "operator": "equal", "operand": "string" }
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment