Visual Studio代码中冒号后如何设置自动插入space?
How to set the insertion of automatic space after a colon in Visual Studio Code?
我想设置如果我写一个冒号,我会在它后面自动添加一个space。我曾经使用 IntelliJ IDEA,它在使用 JSON 时会自动执行此操作。这也可以在VSC中设置吗?
扩展 HyperSnips 是一种实现方式。
在您的 json.hsnips 文件中(因此仅限于 json
个文件):
snippet `:` "expand to : " A
``rv = ': '``
endsnippet
现在,无论何时键入 :
,它都会在 json
文件中扩展为 :
。
有关详细信息,请参阅 。
仅使用 :
作为键绑定中前缀的键是行不通的,因为您必须有修饰键 - 例如 alt、ctrl,等等。参见https://code.visualstudio.com/docs/getstarted/keybindings#_accepted-keys。
你可以这样做:
{
"key": "alt+;", // I chose ; because it is on the same key for me as :
"command": "type",
"args": { "text": ": " },
"when": "editorTextFocus && editorLangId == json"
},
这样就可以了。
我想设置如果我写一个冒号,我会在它后面自动添加一个space。我曾经使用 IntelliJ IDEA,它在使用 JSON 时会自动执行此操作。这也可以在VSC中设置吗?
扩展 HyperSnips 是一种实现方式。
在您的 json.hsnips 文件中(因此仅限于 json
个文件):
snippet `:` "expand to : " A
``rv = ': '``
endsnippet
现在,无论何时键入 :
,它都会在 json
文件中扩展为 :
。
有关详细信息,请参阅
仅使用 :
作为键绑定中前缀的键是行不通的,因为您必须有修饰键 - 例如 alt、ctrl,等等。参见https://code.visualstudio.com/docs/getstarted/keybindings#_accepted-keys。
你可以这样做:
{
"key": "alt+;", // I chose ; because it is on the same key for me as :
"command": "type",
"args": { "text": ": " },
"when": "editorTextFocus && editorLangId == json"
},
这样就可以了。