VScode快捷键设置和代码简写

1 常用快捷键

单行注释

ctrl+/

多行注释

alt+shift+a

复制上一行代码到下一行

alt+shift+↓

移动代码到上一行或下一行

alt+↑, alt+↓

返回到上次编辑位置

alt+←

格式化代码

ctrl+s

替换

ctrl+h

2 快捷键简写设置

snippets设置

  1. shift+ctrl+p
  2. 输入snippets

    VScode快捷键设置和代码简写_第1张图片
  3. 点击go.json

    VScode快捷键设置和代码简写_第2张图片
  4. 在json文件中加入
    // Place your snippets for go 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": "log",
    	// 	"body": [
    	// 		"console.log('$1');",
    	// 		"$2"
    	// 	],
    	// 	"description": "Log output to console"
    	// }
    
    	"pln":{
    		"prefix": "pln",
    		"body": "fmt.Println($0)",
    		"description": "fmt.Println()"
    	},
    	"plf":{
    		"prefix": "plf",
    		"body": "fmt.Printf(\"$0\\n\",)",
    		"description": "fmt.Printf()"
    	}

     

  5. 效果

3 Go语言标准库文档查阅

     中文版

你可能感兴趣的:(VScode快捷键设置和代码简写)