Sublime Forum

Clojure citation mark autocompletes strangely

#1

When I’m coding Clojure (.clj) and type the single citation mark (’) it autocompletes a second, as if I was typing a string in another language.
In clojure however ’ is not used for string, but used to signify the creation of a list (among other things.

So when I create a list
'(1 2 3 4 5 6)
sublime adds an extra ’
which is usually a bit difficult to find…

I’m using Sublime Text, build 3114

0 Likes

#2

You could turn “auto character pairing as you type” off completely, by setting auto_match_enabled to false in your user preferences.

I had the idea that an alternative would be to override the default keybinding for so that it won’t work in a clojure scope, but unfortunately it just falls back to the default which doesn’t have the restriction:

{ "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 - punctuation.definition.string.end", "match_all": true },
        { "key": "selector", "operator": "not_equal", "operand": "source.clojure", "match_all": true },
    ]
},
0 Likes