我正在写一个乳胶文档,我想插入重音字符..
假设我想插入重音 e:è
如果我想写它,我使用:
\`e
但是使用崇高的自动完成功能,当我插入反引号时,我得到
\`e`
所以我每次插入重音字符时都必须删除多余的反引号。如果第一个引号前面有反斜杠,有没有办法避免关闭引号?
谢谢
我正在写一个乳胶文档,我想插入重音字符..
假设我想插入重音 e:è
如果我想写它,我使用:
\`e
但是使用崇高的自动完成功能,当我插入反引号时,我得到
\`e`
所以我每次插入重音字符时都必须删除多余的反引号。如果第一个引号前面有反斜杠,有没有办法避免关闭引号?
谢谢
尝试将以下内容添加到您的用户键绑定中。
{ "keys": ["'"], "command": "insert_snippet", "args": {"contents": "'"}, "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 },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "\\\\$", "match_all": true },
{ "key": "selector", "operator": "equal", "operand": "text.tex", "match_all": true }
]
}
我将现有的键绑定用于默认键绑定中的自动配对引号。然后我更改了代码段,因此它只需输入一个字符。您可以将其更改为insert
命令,但这并不重要。然后我将最后 2 个条目添加到上下文中。第一个检查前面的文本是否存在\
. 第二个将键绑定限制为范围为text.tex.latex
. 第二个条目并不是真正需要的,但如果它不存在,它将适用于所有文件类型,而不仅仅是tex
文件。
编辑
双引号解决方案
{ "keys": ["\""], "command": "insert_snippet", "args": {"contents": "\""}, "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.double", "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "\\\\$", "match_all": true },
{ "key": "selector", "operator": "equal", "operand": "text.tex", "match_all": true }
]
}
重申一下,我从双引号自动配对键绑定(默认)开始,并添加了两个上下文条目。解析失败意味着您有一些格式错误的 json。如果我不得不猜测,你必须有很多/没有足够的\
逃脱。
编辑2
相同的程序。希望这次我得到了正确的报价:)
{ "keys": ["`"], "command": "insert_snippet", "args": {"contents": "`"}, "context":
[
{ "key": "selector", "operator": "equal", "operand": "text.tex.latex"},
{ "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 }
]
}