必备快捷键

快捷键用途 macOS Windows
打开命令面板(Command Palette) Shift-Command-P Shift-Ctrl-P

通过命令面板执行的常用操作

要执行的操作 输入的命令(不需要输全就可以筛选出对应的命令)
code 命令安装到 macOSPATH install code command in path
在内置终端中运行当前编辑器中的文件 run file in terminal
改变文件格式,同时改变语法高亮、代码补全 change language mode
文本折行(Word Wrap) word wrap

必备扩展(Extensions)

通用

  • Vim (by VSCodeVim)
  • Bracket Pair Colorizer 2
  • Git History
  • Python (by Microsoft)
  • Visual Studio IntelliCode (by Microsoft)

Color theme

  • One Dark Pro

Database

  • SQLTools - Database tools

Markdown

  • Markdown All in One
  • Markdown PDF
  • Markdown Preview Enhanced
  • Markdown Table Formatter (by Fernando Crespo)
  • markdownlint

配置文件

  1. 打开命令面板,输入 setting json
  2. 选择 Preferences: Open Settings (JSON)
  3. 复制粘贴以下内容。
  1. {
  2. "editor.cursorSurroundingLines": 1,
  3. "editor.fontSize": 12,
  4. "editor.lineNumbers": "relative",
  5. "editor.rulers": [72, 80],
  6. "vim.camelCaseMotion.enable": true,
  7. "vim.easymotion": true,
  8. "vim.hlsearch": true,
  9. "vim.incsearch": true,
  10. "vim.leader": ",",
  11. "vim.useCtrlKeys": true,
  12. "vim.useSystemClipboard": true,
  13. // "vim.enableNeovim": true,
  14. // "vim.neovimPath": "c:\\Users\\yangl16\\my_portable_apps\\Neovim\\bin\\nvim.exe",
  15. "vim.insertModeKeyBindings": [
  16. {
  17. "before": ["j", "j"],
  18. "after": ["<Esc>"]
  19. }
  20. ],
  21. "vim.normalModeKeyBindings": [
  22. {
  23. "before": ["<space>"],
  24. "after": [":"]
  25. }
  26. ],
  27. "vim.visualModeKeyBindings": [
  28. {
  29. "before": ["<space>"],
  30. "after": [":"]
  31. }
  32. ],
  33. "workbench.activityBar.visible": false,
  34. "workbench.colorTheme": "Quiet Light",
  35. "workbench.startupEditor": "newUntitledFile"
  36. }

用户自定义快捷键

在编辑器和内置终端之间切换焦点

  1. 打开命令面板,输入 keyboard json
  2. 选择 Preferences: Open Keyboard Shortcuts (JSON)
  3. 复制粘贴以下内容。
  1. // Toggle between terminal and editor focus
  2. {
  3. "key": "ctrl+`",
  4. "command": "workbench.action.terminal.focus"
  5. },
  6. {
  7. "key": "ctrl+`",
  8. "command": "workbench.action.focusActiveEditorGroup",
  9. "when": "terminalFocus"
  10. }

编程语言特定配置

改变 Python 解释器

  • 改变特定项目的 Python 解释器
    • 项目根目录下的 .vscode 目录创建 settings.json 文件,添加下面这一行配置:
    • "python.pythonPath": "/usr/local/bin/python3"
      • 备注:/usr/local/bin/python3 是 macOS Homebrew 安装的 Python 3 的路径。
  • 改变所有项目的 Python 解释器
    • 全局配置文件 **settings.json** 中添加下面这一行配置:
    • "python.pythonPath": "/usr/local/bin/python3"