Closed victorandree closed 6 years ago
@vicvicvic Thanks for that. Looks like you can restrict the editing to at least Clojure by adding a scope selector to the context keys, so the above becomes:
// Clojure unmatching of single quotes
[
{
"keys": ["'"],
"command": "insert_snippet",
"args": {
"contents": "'"
},
"context": [
{
"key": "selection_empty",
"operator": "equal",
"operand": true,
"match_all": true
},
{
"key": "selector",
"operator": "equal",
"operand": "source.clojure"
}
]
},
{
"keys": ["'"],
"command": "insert_snippet",
"args": {
"contents": "'${0:$SELECTION}'"
},
"context": [
{
"key": "setting.auto_match_enabled",
"operator": "equal",
"operand": true
},
{
"key": "selection_empty",
"operator": "equal",
"operand": false,
"match_all": true
},
{
"key": "selector",
"operator": "equal",
"operand": "source.clojure"
}
]
},
{
"keys": ["'"],
"command": "noop",
"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": "^'",
"match_all": true
},
{
"key": "selector",
"operator": "equal",
"operand": "source.clojure"
}
]
}
]
Seemed to work for me. I guess you'd change the operator and operand for selector
to regex matching as per: http://docs.sublimetext.info/en/latest/reference/key_bindings.html, to hit all manner of lisps.
The solution posted by @kavington 100% worked for me as well - I was able to use it as-is (sans bookending square brackets) within Preferences --> Key Bindings - User.
On Sublime Text 3, I successfully disabled auto-pairing of single quotes by overriding the relevant key bindings in my User .sublime-keymap as below. It could probably be made more refined by somehow detecting if we're editing lisps, but I'm not sure how!