Skip to content

VS Code Configuration

Essential plugins, settings, and configuration for Visual Studio Code.

Essential Plugins

From the README configuration:

  1. EditorConfig for VS Code

    • Maintains consistent coding styles
    • Reads .editorconfig files
    • Marketplace
  2. ESLint

    • JavaScript/TypeScript linting
    • Auto-fix on save
    • Marketplace
  3. vscode-icons

    • File and folder icons
    • Better visual organization
    • Marketplace

General Development:

  • Prettier - Code formatter
  • GitLens - Enhanced Git integration
  • Path Intellisense - Autocomplete file paths
  • Auto Rename Tag - Auto rename paired HTML/XML tags
  • Bracket Pair Colorizer - Colorize matching brackets

Language Specific:

  • C# Dev Kit - C# development
  • Python - Python support
  • JavaScript (ES6) code snippets - JS snippets
  • Vetur or Volar - Vue.js support
  • ESLint - JavaScript/TypeScript linting

Productivity:

  • Live Share - Real-time collaboration
  • Remote - SSH - Edit files over SSH
  • Docker - Docker container management
  • REST Client - Test APIs directly in VS Code

Themes:

  • One Dark Pro - Popular dark theme
  • Material Icon Theme - Alternative icon theme
  • GitHub Theme - GitHub-style themes

Configuration

settings.json (from README)

Open settings: Ctrl + Shift + P → "Preferences: Open Settings (JSON)"

json
{
    "editor.fontFamily": "'Source Code Pro', Consolas, 'Courier New', monospace",
    "editor.fontSize": 14,
    "window.zoomLevel": 0,
    "workbench.startupEditor": "newUntitledFile",
    "workbench.iconTheme": "vscode-icons",
    "vsicons.presets.foldersAllDefaultIcon": true,
    "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
    "editor.codeActionsOnSave": {
        "source.fixAll.eslint": true
    },
    "workbench.colorCustomizations": {
        "tab.activeBorderTop": "#ff0000"
    }
}

Modern settings.json

Updated configuration with modern VS Code features:

json
{
    // Font settings
    "editor.fontFamily": "'Source Code Pro', 'Cascadia Code', Consolas, 'Courier New', monospace",
    "editor.fontSize": 14,
    "editor.fontLigatures": true,

    // Editor behavior
    "editor.formatOnSave": true,
    "editor.formatOnPaste": true,
    "editor.tabSize": 2,
    "editor.insertSpaces": true,
    "editor.detectIndentation": true,
    "editor.wordWrap": "on",
    "editor.minimap.enabled": true,
    "editor.suggestSelection": "first",
    "editor.bracketPairColorization.enabled": true,
    "editor.guides.bracketPairs": true,

    // Code actions
    "editor.codeActionsOnSave": {
        "source.fixAll.eslint": "explicit",
        "source.organizeImports": "explicit"
    },

    // Workbench
    "workbench.startupEditor": "none",
    "workbench.iconTheme": "vscode-icons",
    "workbench.colorTheme": "One Dark Pro",
    "workbench.editor.enablePreview": false,
    "workbench.colorCustomizations": {
        "tab.activeBorderTop": "#ff0000",
        "editorBracketHighlight.foreground1": "#ffd700",
        "editorBracketHighlight.foreground2": "#da70d6",
        "editorBracketHighlight.foreground3": "#87cefa"
    },

    // Terminal
    "terminal.integrated.fontSize": 13,
    "terminal.integrated.defaultProfile.windows": "PowerShell",
    "terminal.integrated.defaultProfile.linux": "bash",
    "terminal.integrated.defaultProfile.osx": "zsh",

    // Files
    "files.autoSave": "onFocusChange",
    "files.trimTrailingWhitespace": true,
    "files.insertFinalNewline": true,
    "files.exclude": {
        "**/.git": true,
        "**/.DS_Store": true,
        "**/node_modules": true,
        "**/.vscode": false
    },

    // Git
    "git.enableSmartCommit": true,
    "git.confirmSync": false,
    "git.autofetch": true,

    // Language specific
    "[javascript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[typescript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[json]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[html]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[css]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },

    // Extensions
    "vsicons.presets.foldersAllDefaultIcon": true,
    "eslint.validate": [
        "javascript",
        "javascriptreact",
        "typescript",
        "typescriptreact"
    ]
}

Keyboard Shortcuts

Essential Shortcuts

ActionWindows/LinuxmacOS
Command PaletteCtrl + Shift + PCmd + Shift + P
Quick Open FileCtrl + PCmd + P
Toggle TerminalCtrl + `Cmd + `
Toggle SidebarCtrl + BCmd + B
Split EditorCtrl + \Cmd + \
Close EditorCtrl + WCmd + W
SaveCtrl + SCmd + S
Save AllCtrl + K SCmd + K S
FindCtrl + FCmd + F
Find in FilesCtrl + Shift + FCmd + Shift + F
ReplaceCtrl + HCmd + H

Editing Shortcuts

ActionWindows/LinuxmacOS
Multi-cursorCtrl + DCmd + D
Select All OccurrencesCtrl + Shift + LCmd + Shift + L
Column SelectionShift + Alt + DragShift + Option + Drag
Move Line Up/DownAlt + ↑/↓Option + ↑/↓
Copy Line Up/DownShift + Alt + ↑/↓Shift + Option + ↑/↓
Delete LineCtrl + Shift + KCmd + Shift + K
Comment LineCtrl + /Cmd + /
Comment BlockShift + Alt + AShift + Option + A
Format DocumentShift + Alt + FShift + Option + F
Go to LineCtrl + GCmd + G
ActionWindows/LinuxmacOS
Go to DefinitionF12F12
Peek DefinitionAlt + F12Option + F12
Go to SymbolCtrl + Shift + OCmd + Shift + O
Go BackAlt + ←Ctrl + -
Go ForwardAlt + →Ctrl + Shift + -
Open Next EditorCtrl + TabCtrl + Tab
Zen ModeCtrl + K ZCmd + K Z

Custom Keyboard Shortcuts

keybindings.json

Open: Ctrl + Shift + P → "Preferences: Open Keyboard Shortcuts (JSON)"

Duplicate Line (like Visual Studio):

From README tip about making VS Code duplicate like Visual Studio:

json
[
    {
        "key": "ctrl+d",
        "command": "editor.action.copyLinesDownAction",
        "when": "editorTextFocus"
    },
    {
        "key": "ctrl+d",
        "command": "-editor.action.addSelectionToNextFindMatch",
        "when": "editorFocus"
    }
]

Additional useful shortcuts:

json
[
    {
        "key": "ctrl+shift+d",
        "command": "editor.action.duplicateSelection"
    },
    {
        "key": "ctrl+k ctrl+c",
        "command": "editor.action.addCommentLine",
        "when": "editorTextFocus"
    },
    {
        "key": "ctrl+k ctrl+u",
        "command": "editor.action.removeCommentLine",
        "when": "editorTextFocus"
    }
]

Workspace Settings

Create .vscode/settings.json in project root for project-specific settings:

json
{
    "editor.tabSize": 2,
    "files.exclude": {
        "**/node_modules": true,
        "**/.git": true,
        "**/dist": true
    },
    "search.exclude": {
        "**/node_modules": true,
        "**/dist": true
    }
}

Code Snippets

Create custom snippets: Ctrl + Shift + P → "Preferences: Configure User Snippets"

JavaScript/TypeScript snippets:

json
{
    "Console Log": {
        "prefix": "cl",
        "body": [
            "console.log('$1:', $1);"
        ],
        "description": "Console log with label"
    },
    "Arrow Function": {
        "prefix": "af",
        "body": [
            "const ${1:functionName} = (${2:params}) => {",
            "\t$0",
            "}"
        ],
        "description": "Arrow function"
    },
    "Async Arrow Function": {
        "prefix": "aaf",
        "body": [
            "const ${1:functionName} = async (${2:params}) => {",
            "\t$0",
            "}"
        ],
        "description": "Async arrow function"
    }
}

EditorConfig

Create .editorconfig in project root:

ini
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false

[*.py]
indent_size = 4

[Makefile]
indent_style = tab

Opening VS Code from Terminal

macOS (from README)

  1. Open Command Palette: Ctrl + Shift + P
  2. Type: "Shell Command: Install 'code' command in PATH"
  3. Select the command

Then use:

bash
# Open current directory
code .

# Open specific file
code filename.txt

# Open and install extension
code --install-extension esbenp.prettier-vscode

Windows

cmd
:: Already available after installation
code .

Linux

bash
# Usually available after installation
code .

# If not, add to PATH
export PATH="$PATH:/path/to/vscode/bin"

Fonts

Source Code Pro (from README)

Download: Google Fonts - Source Code Pro

Install and configure in settings:

json
{
    "editor.fontFamily": "'Source Code Pro', Consolas, monospace"
}
  • Cascadia Code - Microsoft's coding font with ligatures
  • Fira Code - Popular font with ligatures
  • JetBrains Mono - Designed for developers
  • Hack - Hand-crafted typeface
  • Inconsolata - Monospace font for code

Tips and Tricks

Multi-Cursor Editing

1. Alt + Click: Add cursor
2. Ctrl + Alt + ↑/↓: Add cursor above/below
3. Ctrl + D: Select next occurrence
4. Ctrl + Shift + L: Select all occurrences

Quick File Navigation

1. Ctrl + P: Quick open file
2. Ctrl + P, type @: Go to symbol
3. Ctrl + P, type :: Go to line
4. Ctrl + P, type #: Search workspace symbols

Zen Mode

Press Ctrl + K Z for distraction-free coding.

Format on Save

json
{
    "editor.formatOnSave": true,
    "[javascript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    }
}

Auto Save

json
{
    "files.autoSave": "afterDelay",
    "files.autoSaveDelay": 1000
}

Troubleshooting

ESLint Not Working

  1. Install ESLint extension
  2. Install ESLint in project: npm install --save-dev eslint
  3. Create .eslintrc.json:
    json
    {
        "extends": "eslint:recommended",
        "env": {
            "browser": true,
            "node": true,
            "es6": true
        }
    }
  4. Reload VS Code

Prettier Conflicts with ESLint

bash
npm install --save-dev eslint-config-prettier eslint-plugin-prettier

Update .eslintrc.json:

json
{
    "extends": ["eslint:recommended", "plugin:prettier/recommended"]
}

Terminal Not Opening

Check settings:

json
{
    "terminal.integrated.defaultProfile.windows": "PowerShell"
}

See Also

External Resources

Released under the MIT License.