Skip to main content

VSCode Config

常见配置

自动保存

  • files.autoSave: 控制编辑器在焦点更改时自动保存。
{
"files.autoSave": "onFocusChange"
}

代码编辑区字体大小

  • editor.fontSize: 编辑器字体大小为 16。
  • editor.mouseWheelZoom: 按住 Ctrl 键并滚动鼠标滚轮时对编辑器字体大小进行缩放。
{
"editor.fontSize": 16,
"editor.mouseWheelZoom": true
}

代码自动换行

  • editor.wordWrap: 控制编辑器在窗口边缘自动换行。
{
"editor.wordWrap": "on"
}

渲染空格

  • editor.renderWhitespace: 控制编辑器总是呈现空格字符。
{
"editor.renderWhitespace": "all"
}

设置制表符大小

  • editor.tabSize: 设置制表符大小为 2 个空格。
{ "editor.tabSize": 2 }

标签页多行显示

{ "workbench.editor.wrapTabs": true }

标签页关闭按钮的位置

{ "workbench.editor.tabCloseButton": "left" }

Github Copilot

# from VS Code Quick Open (Ctrl+P)
ext install GitHub.copilot-nightly

# from Command Line
code --install-extension GitHub.copilot-nightly

Assign keyboard shortcuts:

  1. Type CTRL+K then CTRL+S to open Keyboard Shortcuts list.
  2. Search for copilot and assign a shortcut to GitHub Copilot: Generate Code.
    • Accept an inline suggestion: editor.action.inlineSuggest.commit: Tab + Tab (As Tab by default is used to indent code)
    • Open Copilot (10 suggestions in separate pane): github.copilot.generate: Alt + Period (As Alt + Period is used to go to the next line in VSCode)

Default keyboard shortcuts:

  • Accept an inline suggestion: Tab. editor.action.inlineSuggest.commit
  • Dismiss an inline suggestion: Esc. editor.action.inlineSuggest.hide
  • Show next inline suggestion: Alt + ] or Option + ]. editor.action.inlineSuggest.showNext
  • Show previous inline suggestion: Alt + [ or Option + [. editor.action.inlineSuggest.showPrevious
  • Trigger inline suggestion: Alt + \ or Option + \. editor.action.inlineSuggest.trigger
  • Open Copilot (10 suggestions in separate pane): Ctrl + Enter. github.copilot.generate
  • Copilot toggle on/off: No default shortcut. github.copilot.toggleCopilot

Docs:

Markdown

# Learn Authoring Pack
ext install docsmsft.docs-authoring-pack

# Prettier Formatter
ext install esbenp.prettier-vscode

# Smartly paste for Markdown
ext install telesoho.vscode-markdown-paste-image

Assign keyboard shortcuts:

  1. Type CTRL+K then CTRL+S to open Keyboard Shortcuts list.
  2. Search for the command, such as formatBold, for which you want to create a custom keybinding.

Type Ctrl+Shift+P to open the Command Palette, and then type pre open key shortcuts json to open the keybindings.json file.

keybindings.json
[
{
"key": "ctrl+b",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus && !editorReadonly && !vim.active && editorLangId == 'markdown'",
"args": {
"langId": "markdown",
"name": "Insert bold text"
}
},
{
"key": "ctrl+i",
"command": "editor.action.insertSnippet",
"when": "!editorReadonly && editorTextFocus && !vim.active && editorLangId == markdown",
"args": {
"langId": "markdown",
"name": "Insert italic text"
}
},
{
"key": "ctrl+shift+q",
"command": "editor.action.insertSnippet",
"when": "!editorReadonly && editorTextFocus && !vim.active && editorLangId == markdown",
"args": {
"langId": "markdown",
"name": "Insert quoted text"
}
},
{
"key": "ctrl+oem_3",
"command": "editor.action.insertSnippet",
"when": "!editorReadonly && editorTextFocus && !vim.active && editorLangId == markdown",
"args": {
"langId": "markdown",
"name": "Insert code"
}
},
{
"key": "ctrl+shift+k",
"command": "editor.action.insertSnippet",
"when": "!editorReadonly && editorTextFocus && !vim.active && editorLangId == markdown",
"args": {
"langId": "markdown",
"name": "Insert fenced code block"
}
},
{
"key": "ctrl+shift+u",
"command": "editor.action.insertSnippet",
"when": "!editorReadonly && editorTextFocus && !vim.active && editorLangId == markdown",
"args": {
"langId": "markdown",
"name": "Insert unordered list"
}
},
{
"key": "ctrl+shift+o",
"command": "editor.action.insertSnippet",
"when": "!editorReadonly && editorTextFocus && !vim.active && editorLangId == markdown",
"args": {
"langId": "markdown",
"name": "Insert ordered list"
}
},
{
"key": "ctrl+shift+h",
"command": "editor.action.insertSnippet",
"when": "!editorReadonly && editorTextFocus && !vim.active && editorLangId == markdown",
"args": {
"langId": "markdown",
"name": "Insert horizontal rule"
}
},
{
"key": "ctrl+shift+l",
"command": "editor.action.insertSnippet",
"when": "!editorReadonly && editorTextFocus && !vim.active && editorLangId == markdown",
"args": {
"langId": "markdown",
"name": "Insert link"
}
},
{
"key": "ctrl+shift+i",
"command": "editor.action.insertSnippet",
"when": "!editorReadonly && editorTextFocus && !vim.active && editorLangId == markdown",
"args": {
"langId": "markdown",
"name": "Insert image"
}
},
{
"key": "ctrl+1",
"command": "editor.action.insertSnippet",
"when": "!editorReadonly && editorTextFocus && !vim.active && editorLangId == markdown",
"args": {
"langId": "markdown",
"name": "Insert heading level 1"
}
},
{
"key": "ctrl+2",
"command": "editor.action.insertSnippet",
"when": "!editorReadonly && editorTextFocus && !vim.active && editorLangId == markdown",
"args": {
"langId": "markdown",
"name": "Insert heading level 2"
}
},
{
"key": "ctrl+3",
"command": "editor.action.insertSnippet",
"when": "!editorReadonly && editorTextFocus && !vim.active && editorLangId == markdown",
"args": {
"langId": "markdown",
"name": "Insert heading level 3"
}
},
{
"key": "ctrl+4",
"command": "editor.action.insertSnippet",
"when": "!editorReadonly && editorTextFocus && !vim.active && editorLangId == markdown",
"args": {
"langId": "markdown",
"name": "Insert heading level 4"
}
},
{
"key": "ctrl+5",
"command": "editor.action.insertSnippet",
"when": "!editorReadonly && editorTextFocus && !vim.active && editorLangId == markdown",
"args": {
"langId": "markdown",
"name": "Insert heading level 5"
}
},
{
"key": "ctrl+6",
"command": "editor.action.insertSnippet",
"when": "!editorReadonly && editorTextFocus && !vim.active && editorLangId == markdown",
"args": {
"langId": "markdown",
"name": "Insert heading level 6"
}
},
{
"key": "ctrl+shift+d",
"command": "editor.action.insertSnippet",
"when": "!editorReadonly && editorTextFocus && !vim.active && editorLangId == markdown",
"args": {
"langId": "markdown",
"name": "Insert strikethrough"
}
},
{
"key": "ctrl+t",
"command": "editor.action.insertSnippet",
"when": "!editorReadonly && editorTextFocus && !vim.active && editorLangId == markdown",
"args": {
"langId": "markdown",
"name": "Insert table"
}
},
{
"key": "ctrl+shift+x",
"command": "editor.action.insertSnippet",
"when": "!editorReadonly && editorTextFocus && !vim.active && editorLangId == markdown",
"args": {
"langId": "markdown",
"name": "Insert task list"
}
},
{
"key": "ctrl+alt+m",
"command": "editor.action.insertSnippet",
"when": "!editorReadonly && editorTextFocus && !vim.active && editorLangId == markdown",
"args": {
"langId": "markdown",
"name": "Insert inline math"
}
},
{
"key": "ctrl+shift+m",
"command": "editor.action.insertSnippet",
"when": "!editorReadonly && editorTextFocus && !vim.active && editorLangId == markdown",
"args": {
"langId": "markdown",
"name": "Insert fenced math"
}
},
{
"key": "ctrl+alt+n",
"command": "editor.action.insertSnippet",
"when": "!editorReadonly && editorTextFocus && !vim.active && editorLangId == markdown",
"args": {
"langId": "markdown",
"name": "Insert Alert Block"
}
}
]