首页 > 技术文章 > vscode提示快捷键与输入法冲突解决办法

hllive 2022-01-17 14:48 原文

vscode提示快捷键是Ctrl + space(空格 ),但是Ctrl + space是系统输入法切换快捷键,这样就会有冲突
在vscode中按Ctrl + Shift + P 输入key命令keyboard将以下JSON复制进入

// Place your key bindings in this file to override the defaultsauto[]
[
    {
        "key": "alt+oem_2",
        "command": "editor.action.triggerSuggest",
        "when": "editorHasCompletionItemProvider && textInputFocus && !editorReadonly"
    },
    {
        "key": "ctrl+space",
        "command": "-editor.action.triggerSuggest",
        "when": "editorHasCompletionItemProvider && textInputFocus && !editorReadonly"
    }
]

将快捷键重新设置后可以使用Alt + /Ctrl + I代码提示建议

用户代码片段 设置-用户代码片段-vue.json中设置如下
vue3

{
	// Place your snippets for vue here. Each snippet is defined under a snippet name and has a prefix, body and 
	// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
	// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the 
	// same ids are connected.
	// Example:
	"Print to console": {
		"prefix": "vv3",
		"body": [
			"<script lang=\"ts\">",
			"import { defineComponent } from \"vue\";",
			"export default defineComponent({",
			"  name: \"ComponentName\",",
			"  setup() {},",
			"});",
			"</script>",
			"<template>",
			"$1",
			"</template>",
			"<style lang=\"less\" scoped>",
			"</style>"
		],
		"description": "Log output to console"
	}
}

推荐阅读