[英]VS Code - Key bindings - cursor position for *type* command
我正在使用 VS 代码版本:1.40.0。
为了加快我的开发速度,我需要设置自己的键绑定,以便在代码中输入特定文本(“ {|print_x} ”)。 我设法做到了,但如果我粘贴文本后 cursor 类型会在“ { ”之后立即跳转,那就更好了。
所以: {这里输入 curosor |print_x} 。
keybindings.json中的代码:
{
"key": "shift+alt+y",
"command": "type",
"args": { "text": "{|print_x}", },
"when": "editorTextFocus"
}
我认为使用这样的数组可能会起作用,但不幸的是text参数需要是字符串。
"args": { "text": [ "{" , "|print_x}" ], }
有没有办法做到这一点? 如果是这样,我将非常感谢。
只需使用此表单即可:
{
"key": "shift+alt+y",
"command": "editor.action.insertSnippet",
"args": {
"snippet": "{$1print_x}"
},
"when": "editorTextFocus"
}
因为这使用了insertSnippet
命令,所以您现在可以直接在键绑定中使用制表位或变量转换,而无需单独的片段。 所以 cursor 将 go 到他$1
所在的位置。
insertSnippet
可以做type
命令所做的事情并为您提供制表位。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.