C'è un modo per ottenere un tipo di sintassi per definire le scorciatoie da tastiera o per impostare una scorciatoia da tastiera per dipendere dal tipo di sintassi (forse sotto l'impostazione "context"
)?Testo sublime e Clojure: non associare le virgolette singole
Le mie liste quotate '(1 2 3)
sono immesse in questo modo: '(1 2 3)'
perché Sublime applica questo comportamento utile (ma non in questo caso).
Ecco il bit rilevante del file Default (OSX).sublime-keymap
// Auto-pair single quotes
{ "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 },
{ "key": "preceding_text", "operator": "not_regex_contains", "operand": "['a-zA-Z0-9_]$", "match_all": true },
{ "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.single", "match_all": true }
]
},
{ "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 }
]
},
{ "keys": ["'"], "command": "move", "args": {"by": "characters", "forward": true}, "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 }
]
},
Non c'è un modo più semplice? potresti forse mettere una frase o due sul perché non continuare a usare "auto_match_enabled'? –
Divertente, stavo pensando che dovrei spiegarlo. Ad ogni modo, ho aggiornato la risposta. Ho anche aggiunto un'opzione alternativa, in cui è possibile modificare il file predefinito. L'unica cosa da notare è che se dovessi mai ripristinare o fare qualsiasi tipo di aggiornamento, il file potrebbe essere spazzato via. Sebbene ST2 non sembri, riceverà aggiornamenti, quindi potrebbe andar bene. La modifica del file predefinito comporterebbe semplicemente l'aggiunta del contesto selettore alle voci predefinite. – skuroda
Beh, sicuramente sarò su ST3 ma potrei lavorare su Windows in ST2. Dovrebbe essere possibile sovrascrivere un keymapping predefinito semplicemente riprogettandolo nel file utente. –