I am using the following snippet in the key binding file to automatically close a square bracket and put a leading and trailing spance.
// Auto-pair square brackets
{ "keys": ["["], "command": "insert_snippet", "args": {"contents": "[$0]"}, "context":
    [
        { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
        { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
        { "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|;|\\}|$|,)", "match_all": true }
    ]
},
So, when I type [ it gets converted to [ | ]. Now what I want to do is, after this, when I type ' or ", the leading and trailing spaces get deleted.
Type: [
Result: [ | ]
Type: [ ' ]
Result: ['|']
Can anyone help me with this?