正在加载,请稍候…

VS Code Productivity: Essential Extensions and Keyboard Shortcuts

Maximize VS Code productivity with essential extensions, keyboard shortcuts, workspace configuration, debugging setup, and custom snippets for professional development.

VS Code Productivity Guide

Essential Extensions

// Essential extensions list
{
  "recommendations": [
    // Language support
    "dbaeumer.vscode-eslint",
    "esbenp.prettier-vscode",
    "ms-python.python",
    "ms-python.pylance",
    "golang.go",

    // Git
    "eamodio.gitlens",
    "mhutchie.git-graph",

    // AI assistance
    "github.copilot",
    "github.copilot-chat",

    // Navigation
    "alefragnani.bookmarks",
    "yzhang.markdown-all-in-one",

    // Productivity
    "formulahendry.code-runner",
    "streetsidesoftware.code-spell-checker",
    "editorconfig.editorconfig",

    // Docker/K8s
    "ms-azuretools.vscode-docker",
    "ms-kubernetes-tools.vscode-kubernetes-tools",

    // REST
    "humao.rest-client",
    "rangav.vscode-thunder-client"
  ]
}

Workspace Settings

// .vscode/settings.json
{
  "editor.formatOnSave": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": "explicit",
    "source.organizeImports": "explicit"
  },
  "editor.tabSize": 2,
  "editor.insertSpaces": true,
  "editor.fontSize": 14,
  "editor.fontFamily": "JetBrains Mono, Fira Code, Cascadia Code",
  "editor.fontLigatures": true,
  "editor.minimap.enabled": false,
  "editor.suggestSelection": "first",
  "editor.bracketPairColorization.enabled": true,
  "editor.guides.bracketPairs": true,
  "editor.rulers": [80, 100, 120],
  
  "terminal.integrated.fontFamily": "JetBrains Mono",
  "terminal.integrated.fontSize": 13,

  "files.trimTrailingWhitespace": true,
  "files.insertFinalNewline": true,
  "files.exclude": {
    "**/.git": true,
    "**/node_modules": true,
    "**/__pycache__": true
  },

  "[typescript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[python]": {
    "editor.defaultFormatter": "ms-python.black-formatter"
  }
}

Key Bindings

// keybindings.json
[
  // Multi-cursor
  { "key": "cmd+d", "command": "editor.action.addSelectionToNextFindMatch" },
  { "key": "cmd+shift+l", "command": "editor.action.selectHighlights" },

  // Navigation
  { "key": "ctrl+tab", "command": "workbench.action.quickOpenPreviousRecentlyUsedEditor" },
  { "key": "cmd+shift+e", "command": "workbench.view.explorer" },
  { "key": "cmd+shift+g", "command": "workbench.view.scm" },

  // Terminal
  { "key": "ctrl+`", "command": "workbench.action.terminal.toggleTerminal" },
  { "key": "cmd+shift+`", "command": "workbench.action.terminal.new" },

  // Code actions
  { "key": "cmd+.", "command": "editor.action.quickFix" },
  { "key": "f2", "command": "editor.action.rename" },
  { "key": "shift+alt+f", "command": "editor.action.formatDocument" },

  // Folding
  { "key": "cmd+shift+[", "command": "editor.fold" },
  { "key": "cmd+shift+]", "command": "editor.unfold" },
  { "key": "cmd+k cmd+0", "command": "editor.foldAll" },
  { "key": "cmd+k cmd+j", "command": "editor.unfoldAll" }
]

Custom Snippets

// typescript.json snippets
{
  "React Function Component": {
    "prefix": "rfc",
    "body": [
      "import type { FC } from 'react'",
      "",
      "interface ${1:Component}Props {",
      "  $2",
      "}",
      "",
      "export const ${1:Component}: FC<${1:Component}Props> = ({ $3 }) => {",
      "  return (",
      "    <div>",
      "      $0",
      "    </div>",
      "  )",
      "}",
      ""
    ]
  },
  "Console log with label": {
    "prefix": "cll",
    "body": ["console.log('${1:label}:', $1)"]
  },
  "Try catch async": {
    "prefix": "tca",
    "body": [
      "try {",
      "  $1",
      "} catch (error) {",
      "  console.error('${2:Error}:', error)",
      "  throw error",
      "}"
    ]
  }
}

Debug Configuration

// .vscode/launch.json
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Debug Node.js",
      "type": "node",
      "request": "launch",
      "program": "${workspaceFolder}/src/server.ts",
      "runtimeArgs": ["--loader", "ts-node/esm"],
      "sourceMaps": true,
      "envFile": "${workspaceFolder}/.env",
      "console": "integratedTerminal"
    },
    {
      "name": "Debug Jest",
      "type": "node",
      "request": "launch",
      "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/jest",
      "args": ["--runInBand", "--no-coverage", "${fileBasenameNoExtension}"],
      "sourceMaps": true,
      "console": "integratedTerminal"
    },
    {
      "name": "Attach to Docker",
      "type": "node",
      "request": "attach",
      "port": 9229,
      "address": "localhost",
      "sourceMaps": true,
      "remoteRoot": "/app",
      "localRoot": "${workspaceFolder}"
    }
  ]
}

Essential Shortcuts

Action Mac Win/Linux
Command palette Cmd+Shift+P Ctrl+Shift+P
Quick open file Cmd+P Ctrl+P
Go to symbol Cmd+Shift+O Ctrl+Shift+O
Go to definition F12 F12
Peek definition Alt+F12 Alt+F12
Find all refs Shift+F12 Shift+F12
Rename symbol F2 F2
Multi-cursor select Cmd+D Ctrl+D
Move line up/down Alt+Up/Down Alt+Up/Down
Toggle comment Cmd+/ Ctrl+/