Skip to content

Instantly share code, notes, and snippets.

@ivan
Last active June 30, 2024 22:05
Show Gist options
  • Save ivan/ab5d11cc5f25fd2febc4925f38f26168 to your computer and use it in GitHub Desktop.
Save ivan/ab5d11cc5f25fd2febc4925f38f26168 to your computer and use it in GitHub Desktop.
Less-annoying vscode configuration

Useful extensions

settings.json

For documentation on all these settings and their default values, refer to https://code.visualstudio.com/docs/getstarted/settings

Only the first section here ("Higher-confidence settings") can be copied without alteration. The other sections require reading and maybe making changes.

{
    // # Higher-confidence settings that you might try and see if you can get used to

    // Opt out of Microsoft telemetry and experimentation
    "telemetry.telemetryLevel": "off",
    "workbench.settings.enableNaturalLanguageSearch": false,
    "workbench.enableExperiments": false,
    "python.experiments.enabled": false,
    // Don't automatically update extensions: we might be trying to get some work done with
    // known-good versions of our extensions.
    "extensions.autoUpdate": false,
    // The end-of-line character should always be just LF, even on Windows. Microsoft programmers
    // and others mistakenly believe they need to be using CR LF on Windows, and will often configure
    // git to automatically translate between CR LF and LF. There's really no need for that.
    "files.eol": "\n",
    // Make it possible to visually distinguish space and tabs; .editorconfig is frequently missing,
    // or things otherwise become indented incorrectly, and we want to notice early.
    "editor.renderWhitespace": "all",
    // For files indented with spaces: when selecting the indentation or moving the cursor,
    // behave as if e.g. 4 spaces were a tab; move 4 spaces at a time.
    "editor.stickyTabStops": true,
    // The minimap (the thumbnail of the code in the top-right) is a meme copied from
    // Sublime Text in the early days of vscode. There's no need for the minimap.
    "editor.minimap.enabled": false,
    // This takes up precious vertical space; files can be switched using keyboard shortcuts instead
    "window.commandCenter": false,
    // This also takes up precious vertical space
    "workbench.layoutControl.enabled": false,
    // vscode defaults to jumpy per-line scrolling, but there's no reason not to scroll better
    // like Sublime Text does. It's still quick and doesn't slow things down.
    "editor.smoothScrolling": true,
    // Accept suggestions only when pressing Tab, not Enter. Enter is for new lines.
    "editor.acceptSuggestionOnEnter": "off",
    // Disable all "smart" autoinsertion of characters that you did not type.
    // Frequently guesses wrong (about whether you need the closing pair), and it's more
    // maddening than just e.g. typing both quote characters yourself and then moving the
    // cursor inside the string.
    "editor.autoClosingBrackets": "never",
    "editor.autoClosingComments": "never",
    "editor.autoClosingOvertype": "never",
    "editor.autoClosingQuotes": "never",
    "editor.autoClosingDelete": "never",
    "editor.autoSurround": "never",
    "html.autoClosingTags": false,
    "html.autoCreateQuotes": false,
    // Disable sticky scroll in the editor and workbench tree: it tries to be helpful by showing
    // the name for e.g. the long function you're in, but the sticky heading can also mislead you
    // into thinking you're looking at the entire function when you are not.
    "editor.stickyScroll.enabled": false,
    "workbench.tree.enableStickyScroll": false,
    // The additional colors are distracting and there's no need for them: files are usually
    // well-formatted, and vscode highlights the opening or closing bracket when you move your
    // cursor to one of the brackets.
    "editor.bracketPairColorization.enabled": false,
    // There's no need to blink the cursor: vscode makes the cursor easy to see by highlighting
    // the line the cursor is on, and by highlighting the line number in the left gutter.
    "editor.cursorBlinking": "solid",
    // Drag and drop of text is more likely to be a mistake than something intended.
    "editor.dragAndDrop": false,
    // Inlay hints (showing e.g. type information) can introduce a lot of noise and make it
    // slightly harder to edit text around the inlay hints. Disable all inlay hints and
    // (in keybindings.json), configure e.g. alt-e to toggle them `on` manually when desired,
    // using Peng Lv's 'Toggle' extension. https://marketplace.visualstudio.com/items?itemName=rebornix.toggle
    "editor.inlayHints.enabled": "off",
    // Enable _all_ the available inlay hints for JavaScript and TypeScript, since we usually
    // keep them off anyway, and when we temporarily toggle them on, we want all the information.
    "javascript.inlayHints.enumMemberValues.enabled": true,
    "javascript.inlayHints.functionLikeReturnTypes.enabled": true,
    "javascript.inlayHints.parameterNames.enabled": "all",
    "javascript.inlayHints.propertyDeclarationTypes.enabled": true,
    "javascript.inlayHints.parameterTypes.enabled": true,
    "javascript.inlayHints.variableTypes.enabled": true,
    "typescript.inlayHints.parameterNames.enabled": "all",
    "typescript.inlayHints.enumMemberValues.enabled": true,
    "typescript.inlayHints.functionLikeReturnTypes.enabled": true,
    "typescript.inlayHints.parameterTypes.enabled": true,
    "typescript.inlayHints.propertyDeclarationTypes.enabled": true,
    "typescript.inlayHints.variableTypes.enabled": true,
    // When navigating to definition, prefer the source instead of the type definition
    "javascript.preferGoToSourceDefinition": true,
    "typescript.preferGoToSourceDefinition": true,
    // Red squigglies are too severe for eslint errors; make all eslint issues yellow instead.
    // https://stackoverflow.com/questions/45899011/change-squiggly-line-color-under-warnings-in-vscode
    "eslint.rules.customizations": [
        { "rule": "*", "severity": "warn" },
    ],
    // Start new vscode windows maximized.
    "window.newWindowDimensions": "maximized",
    // Always open folders in new windows, don't let vscode decide based on the context.
    "window.openFoldersInNewWindow": "on",
    // When starting vscode by opening some folder or file, don't discard all of our previously-open windows.
    "window.restoreWindows": "preserve",
    // Begin the window title with the name of the project (folder name), so that we can
    // distinguish multiple vscode windows in our taskbar.
    "window.title": "${dirty}${rootName}",
    // Use native menus and titlebars to match other applications and reduce
    // cognitive load ("which part of the window can I drag?")
    "window.titleBarStyle": "native",
    // We zoom when our eyes our tired or because we're sharing our screen, and
    // that should be applied to all vscode windows.
    "window.zoomPerWindow": false,
    // In the file tree, significantly increase the indentation width, so that can we can
    // easily see that a file is in some folder.
    "workbench.tree.indent": 19,
    // Restore the previous command when activating the command palette.
    // This makes it function more like Emacs + amx's alt-x and makes it easier to repeat a command.
    "workbench.commandPalette.preserveInput": true,
    // vscode's language detection is very annoying and highlights plain text as some random language
    "workbench.editor.languageDetection": false,
    // Don't show the welcome page when starting vscode
    "workbench.startupEditor": "none",

    // # Things to consider and tweak yourself

    // Don't show prominent and useless underlines under each URL. Unfortunately, this also prevents you
    // from being able to visit the URL via the context menu.
    "editor.links": false,
    // Don't give up on trying to syntax-highlight large files
    "editor.largeFileOptimizations": false,
    // 'Easy icon theme' by James Maguire
    // https://marketplace.visualstudio.com/items?itemName=jamesmaj.easy-icons
    "workbench.iconTheme": "easy-icons",
    // How much vscode scrolls per mousewheel turn. Try to make this match another
    // application you use, like your browser?
    "editor.mouseWheelScrollSensitivity": 0.53,
    // If you use a package manager e.g. chocolatey on Windows to update vscode,
    // there's no need to have vscode check for updates.
    "update.mode": "none",
    "update.enableWindowsBackgroundUpdates": false,
    // You can always read vscode's release notes at https://code.visualstudio.com/updates/ instead
    "update.showReleaseNotes": false,
    // Disable notifications for recommended extensions
    "extensions.ignoreRecommendations": true,
    // Colors you might tweak to override unhappy aspects of the theme you're using
    // "workbench.colorCustomizations": {
    //     "activityBarBadge.background": "#0000",
    //     "activityBarBadge.foreground": "#cccc",
    //     "editor.background": "#111",
    //     "editor.findMatchBackground": "#0000ff",
    //     "editor.findMatchHighlightBackground": "#3a3ab3",
    //     "editor.selectionBackground": "#446f",
    // },
    // "editor.tokenColorCustomizations": {
    //     "comments": {
    //         // Disable italic
    //         "fontStyle": "",
    //         "foreground": "#999"
    //     }
    // },

    // # Font settings in case you have a good font installed like PragmataPro Mono

    // Is this still the best monospace font free of ligatures? It has nice horizontal compression
    // so that many characters fit per line, but there are also several imitators now.
    "editor.fontFamily": "PragmataPro Mono",
    "editor.fontSize": 12,
    // We want as many lines on screen as we can fit without impairing our ability to read code.
    "editor.lineHeight": 13,

    // # Svelte and SvelteKit-specific

    // For SvelteKit files e.g. +page.svelte, show "folder/+page.svelte" instead of just "+page.svelte"
    "workbench.editor.customLabels.patterns": {
        "**/+*": "${dirname}/${filename}.${extname}"
    },
    // "Enables a TypeScript plugin which provides intellisense for Svelte files inside TS/JS files. Default: false"
    "svelte.enable-ts-plugin": true,
    // By default, after tab-completing an import, the Svelte extension (ignoring your .editorconfig)
    // inserts lines indented with spaces instead of tabs. https://github.com/sveltejs/language-tools/issues/1997
	"prettier.useTabs": true,
    "prettier.tabWidth": 4,

    // # Try to improve the security of 'Remote - SSH'

    "remote.SSH.enableAgentForwarding": false,
    "remote.SSH.remoteServerListenOnSocket": true,
    "remote.autoForwardPorts": false,
}

keybindings.json

Don't copy anything from here without thinking about it and testing.

[
    // The idea here isn't necessarily to use these exact shortcuts, but to assign
    // keys you can comfortably press with one hand for the most frequently-used commands.
    // I used alt-x (command palette) and alt-q (file switcher) because I was already
    // used to having these in Emacs and my customized Sublime Text.
    {"key": "alt+x",         "command": "workbench.action.showCommands"},
    {"key": "ctrl+shift+p",  "command": "-workbench.action.showCommands"},
    {"key": "alt+q",         "command": "workbench.action.quickOpen"},
    {"key": "ctrl+e",        "command": "-workbench.action.quickOpen"},
    {"key": "ctrl+shift+l",  "command": "editor.action.insertCursorAtEndOfEachLineSelected", "when": "editorTextFocus"},
    {"key": "shift+alt+i",   "command": "-editor.action.insertCursorAtEndOfEachLineSelected", "when": "editorTextFocus"},
    {"key": "alt+left",      "command": "workbench.action.navigateBack"},
    {"key": "ctrl+alt+-",    "command": "-workbench.action.navigateBack"},
    {"key": "alt+\\",        "command": "workbench.action.navigateToLastEditLocation"},
    {"key": "ctrl+k ctrl+q", "command": "-workbench.action.navigateToLastEditLocation"},
    {"key": "alt+right",     "command": "workbench.action.navigateForward"},
    {"key": "ctrl+shift+-",  "command": "-workbench.action.navigateForward"},
    {"key": "ctrl+q",        "command": "-workbench.action.quickOpenView"},
    {"key": "ctrl+q",        "command": "workbench.action.quit"},
    {"key": "ctrl+m",        "command": "magit.status"},
    {"key": "alt+x g",       "command": "-magit.status"},

    // The toggle commands below require Peng Lv's 'Toggle' extension.
    // https://marketplace.visualstudio.com/items?itemName=rebornix.toggle

    // Key binding to toggle inlay hints. This is probably the only toggle you might want to copy.
    {
        "key": "alt+e",
        "command": "toggle",
        "when": "editorTextFocus",
        "args": {
            "id": "inlayHints",
            "value": [
                {"editor.inlayHints.enabled": "on"},
                {"editor.inlayHints.enabled": "off"}
            ]
        }
    },

    // Example for switching between a monospace and variable-width font.
    {
        "key": "alt+d",
        "command": "toggle",
        "args": {
            "id": "Cycle font",
            "value": [
                {
                    "editor.fontSize": 14,
                    "editor.lineHeight": 16,
                    "editor.fontFamily": "Inter Display",
                    "editor.tabSize": 6,
                },
                {
                    "editor.fontSize": 12,
                    "editor.lineHeight": 13,
                    "editor.fontFamily": "PragmataPro Mono",
                    "editor.tabSize": 4,
                },
            ]
        }
    },

    // Example for switching many settings with one keystroke, if you use e.g. SyncThing to
    // sync your vscode settings, but need some settings to be different on two machines.
    {
        "key": "ctrl+alt+m",
        "command": "toggle",
        "args": {
            "id": "Settings for other machine",
            "value": [
                // desktop
                {
                    "editor.fontSize": 12,
                    "editor.lineHeight": 13,
                    "editor.mouseWheelScrollSensitivity": 0.53,
                    "workbench.colorCustomizations": {
                        "activityBarBadge.background": "#0000",
                        "activityBarBadge.foreground": "#cccc",
                        "editor.background": "#111",
                        "editor.findMatchBackground": "#0000ff",
                        "editor.findMatchHighlightBackground": "#3a3ab3",
                        "editor.selectionBackground": "#446f"
                    },
                },
                // laptop
                {
                    "editor.fontSize": 12,
                    "editor.lineHeight": 13,
                    "editor.mouseWheelScrollSensitivity": 1,
                    "workbench.colorCustomizations": {
                        "activityBarBadge.background": "#0000",
                        "activityBarBadge.foreground": "#cccc",
                        "editor.background": "#000",
                        "editor.findMatchBackground": "#0000ff",
                        "editor.findMatchHighlightBackground": "#3a3ab3",
                        "editor.selectionBackground": "#446f"
                    },
                },
            ]
        }
    },
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment