gpt4 book ai didi

clojure - Sublime Text 和 Clojure : Don't pair single quotes

转载 作者:太空宇宙 更新时间:2023-11-03 18:33:02 25 4
gpt4 key购买 nike

有没有办法获取语法类型来定义键盘快捷键,或者将键盘快捷键设置为取决于语法类型(可能在 "context" 下)设置?

我的引用列表 '(1 2 3) 像这样输入:'(1 2 3)' 因为 Sublime 应用了这个有用的(但不是在这种情况下) ) 行为。

这是 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 }
]
},

最佳答案

我做了这件简单的事:
这个:

// Singlequote for lisp
{ "keys": ["'"], "command": "insert_snippet", "args": {"contents": "'"}, "context":
[
{ "key": "selector", "operator": "equal", "operand": "source.lisp"}
]
},

在您的用户键绑定(bind)中。


更进一步:

在这种情况下还有一个不寻常的情况: '|' (管道代表插入符),按退格键后,它仍然会删除两个单引号。


要解决此问题,请将this 添加到您的user-key-keybindings:

{ "keys": ["backspace"], "command": "left_delete", "context":
[
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "'$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^'", "match_all": true },
{ "key": "selector", "operator": "equal", "operand": "source.lisp"}
]
},

重要提示:

正如匹克威克在评论中所说,你当然应该改变

"source.lisp"

"source.<lisp-of-your-choice>"
或者更确切地说
"source.<name-of-syntax-of-your-choice>"
甚至更确切地说:
"source.<name-of-scope-the-syntax-you're-using-is-using>" .


ScopeAlways 是一个插件,可以向您显示您的语法正在使用的范围 的正确名称。它很可能会是类似 "source.lisp" 的东西。对于 CL,"source.clojure"对于 Clojure,可能是 "source.scheme"如果你和很酷的 children 出去玩,等等......

关于clojure - Sublime Text 和 Clojure : Don't pair single quotes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15845543/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com