Mine is a bit more complicated, but features a lot of behaviors that I like.
- Code: Select all
{ "keys": ["tab"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
[
{ "key": "selection_empty", "operator": "equal", "operand": true },
{ "key": "preceding_text", "operator": "not_regex_match", "operand": "[[:space:]]*", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^[\"'\\)\\}\\]]", "match_all": true },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false },
{ "key": "has_next_field", "operator": "equal", "operand": false }
]
},
{ "keys": ["tab"], "command": "move", "args": {"by": "words", "forward": true}, "context":
[
{ "key": "selection_empty", "operator": "equal", "operand": true},
{ "key": "preceding_text", "operator": "not_regex_match", "operand": "[[:space:]]*", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^[.,:;]", "match_all": true },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false },
{ "key": "has_next_field", "operator": "equal", "operand": false }
]
},
{ "keys": ["tab"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
[
{ "key": "selection_empty", "operator": "equal", "operand": true},
{ "key": "selector", "operator": "equal", "operand": "text.tex.latex", "match_all": true },
{ "key": "preceding_text", "operator": "not_regex_match", "operand": "[[:space:]]*", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^[$]", "match_all": true },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false },
{ "key": "has_next_field", "operator": "equal", "operand": false }
]
}
The other keybindings I've found tend to not factor in whether the bracket or quote is at the beginning of the line, so they didn't work for me. I want
- Code: Select all
^|"Hello!"
to become
- Code: Select all
^ |"Hello"
instead of
- Code: Select all
^"|Hello"
('^' is the start of the line, and '|' is the cursor position). When I'm at the beginning of the line, I almost always want to indent, so I've factored that in. I also use tab to skip over common punctuation, and in that case, I want to skip to the next word, not just one character to the right. And finally, I write quite a bit in LaTeX, so I added a special case for LaTeX's inline math.
Hopefully, this'll be of use to someone.