Table of Contents

My Own VS Code

Summary: I use VS Code in my day to day life for a lot. It took me a while to get to know it but it made my (work) life a lot easier. Each time I get a new computer or workplace I follow these steps. And as automation should make everyone's life a lot easier, I made a settings and extension file so I don't have to do a lot of settings manually anymore.
Date: Around 2020
Refactor: 2 January 2025: Checked links and formatting. Added new notes, extensions, profiles.

Program Installation

Start with Git and then VS Code.

Git Installation

Once the installation is done, start Git Bash from the start menu and enter the following commands to set your username and email address:

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

Use Windows Certificate Store

If the git server changes certificates, you'll also need to update your Git's Certificate store. In a managed environment it might be better to use the Windows Certificate store:

  git config --global http.sslBackend schannel
Note that this is possible starting Git 2.14

Overview Git Settings

git config --global credential.usehttppath true
git config --global --list
 
core.editor="C:\Users\sjoer\AppData\Local\Programs\Microsoft VS Code\bin\code" --wait
user.email=sjoerd@xxx.xxx
user.name=Sjoerd Hooft
credential.usehttppath=true
http.sslbackend=schannel

See here for more information on the usehttppath in combination with dev.azure.com.

Visual Studio Code Installation

User Settings

Note that some settings can also be synced between devices using the Settings Sync feature.

Use “ctrl-shift-p” “Preferences: Open User Settings (JSON)” to open your user settings and add the following preferences:

{
  "editor.renderWhitespace": "all",
  "workbench.colorCustomizations": {
    "tab.activeBorder": "#ff0000",
    "tab.unfocusedActiveBorder": "#000000"
  },
  "workbench.editor.enablePreview": false
}

Profiles

Profiles are useful for limiting the extensions loaded into VSCode. If you enable the sync options above you can select to sync profiles. Per profile you can simply add and remove extensions.

Repo Settings and Extensions

In your repo, create the following folder and files:

settings.json
// https://code.visualstudio.com/docs/getstarted/settings#_workspace-settings
{
    "editor.rulers": [
        {
            "color": "#c58414",
            "column": 100
        },
        {
            "color": "#ab0707",
            "column": 120
        }
    ],
    "editor.codeActionsOnSave": {
        "source.fixAll.markdownlint": "explicit"
    },
    "editor.defaultFormatter": null,
    "editor.formatOnSave": true,
    "editor.formatOnPaste": true,
    "editor.tabSize": 4,
    "editor.insertSpaces": true,
    "editor.renderWhitespace": "all",
    "editor.renderControlCharacters": true,
    "files.insertFinalNewline": true,
    "files.trimFinalNewlines": true,
    "files.trimTrailingWhitespace": true,
    "files.eol": "\n",
    "files.associations": {
        "*.md": "markdown",
        "**/*.yml": "azure-pipelines",
        "**/arm-*.json": "arm-template",
        "*.json": "json",
        "*.xml": "xml",
        "*.nuspec": "xml",
        "*.config": "xml",
        "*.sql": "sql",
        "*.tf": "terraform",
        "*.tfvars": "terraform",
        ".github/workflow/*.yml": "github-actions"
    },
    "[terraform]": {
        "editor.defaultFormatter": "hashicorp.terraform"
    },
    "[azure-pipelines]": {
        // no format, keep outlined comments and variables
        "editor.formatOnSave": false,
        "editor.formatOnPaste": false
        //"editor.defaultFormatter": "esbenp.prettier-vscode",
    },
    "[plaintext]": {
        "editor.unicodeHighlight.ambiguousCharacters": true,
        "editor.unicodeHighlight.invisibleCharacters": true,
        "editor.formatOnSave": false,
        "files.insertFinalNewline": false
    },
    "[markdown]": {
        "editor.defaultFormatter": "yzhang.markdown-all-in-one",
        "files.trimTrailingWhitespace": true,
        "files.insertFinalNewline": true
    },
    "[powershell]": {
        "editor.defaultFormatter": "ms-vscode.powershell",
        "editor.language.brackets": [
            [
                "{",
                "}"
            ],
            [
                "(",
                ")"
            ],
            [
                "#region",
                "#endregion"
            ]
        ]
    },
    "[csharp]": {
        "editor.defaultFormatter": "csharpier.csharpier-vscode"
    },
    "[bicep]": {
        "editor.defaultFormatter": "ms-azuretools.vscode-bicep",
        "editor.tabSize": 2
    },
    "[css]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode",
        "editor.suggest.insertMode": "replace"
    },
    "[html]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode",
        "editor.suggest.insertMode": "replace",
        "editor.formatOnType": true
    },
    "[javascript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[arm-template]": {
        "editor.defaultFormatter": "msazurermtools.azurerm-vscode-tools"
    },
    "[github-actions]": {
        "editor.defaultFormatter": "github.vscode-github-actions"
    }
    "files.autoSave": "off",
    "git.autofetch": true,
    "markdown.extension.tableFormatter.normalizeIndentation": true,
    "markdown.extension.orderedList.autoRenumber": false,
    "powershell.codeFormatting.autoCorrectAliases": true,
    "powershell.codeFormatting.useCorrectCasing": true,
    "powershell.codeFormatting.alignPropertyValuePairs": true,
    "powershell.codeFormatting.addWhitespaceAroundPipe": true,
    "powershell.codeFormatting.avoidSemicolonsAsLineTerminators": false,
    "powershell.codeFormatting.ignoreOneLineBlock": true,
    "powershell.codeFormatting.openBraceOnSameLine": true,
    "powershell.codeFormatting.trimWhitespaceAroundPipe": true,
    "powershell.codeFormatting.whitespaceAfterSeparator": true,
    "powershell.codeFormatting.whitespaceAroundOperator": true,
    "powershell.codeFormatting.whitespaceBeforeOpenBrace": true,
    "powershell.codeFormatting.newLineAfterOpenBrace": true,
    "powershell.codeFormatting.whitespaceBeforeOpenParen": true,
    "powershell.codeFormatting.newLineAfterCloseBrace": true,
    "powershell.codeFormatting.whitespaceInsideBrace": true,
    "powershell.codeFormatting.whitespaceBetweenParameters": false,
    "powershell.codeFormatting.useConstantStrings": false,
    "powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationForFirstPipeline", // https://learn.microsoft.com/en-us/powershell/utility-modules/psscriptanalyzer/rules/useconsistentindentation
    "powershell.codeFormatting.preset": "OTBS", //https://poshcode.gitbook.io/powershell-practice-and-style/style-guide/code-layout-and-formatting#one-true-brace-style
    "powershell.integratedConsole.showOnStartup": true,
    "powershell.integratedConsole.suppressStartupBanner": true,
    "powershell.powerShellDefaultVersion": "PowerShell (x64)",
    "powershell.promptToUpdatePowerShell": true,
    "prettier.disableLanguages": [
        "yml",
        "yaml",
    ],
    "window.title": "${folderName}" //https://code.visualstudio.com/updates/v1_10#_configurable-window-title
}
extensions.json
{
    "recommendations": [
        // AWS
        "amazonwebservices.aws-toolkit-vscode", // AWS Toolkit, SAM, Lambda, Step functions, S3
        // Azure
        "msazurermtools.azurerm-vscode-tools", // Azure ARM
        "ms-azuretools.vscode-bicep", // Azure BICEP
        "ms-azure-devops.azure-pipelines", // Azure pipelines
        "ms-vscode.azurecli", // Azure CLI
        // csharp
        "ms-dotnettools.csdevkit", // csharp development kit
        "csharpier.csharpier-vscode", // formatter
        // Docker
        "ms-azuretools.vscode-docker", // Docker
        // Formatting
        "esbenp.prettier-vscode", // Default formatting - note that prettier can try to be very persuasive. Use save without formatting when required.
        // Git
        "niclasvaneyk.am-i-behind", // Checks for commits in remote repo
        "mhutchie.git-graph", // Git graph
        "eamodio.gitlens", // Git Lens
        // GitHub Actions
        "github.vscode-github-actions",
        // Kubernetes
        "ms-kubernetes-tools.vscode-kubernetes-tools", // Kubernetes
        "ms-vscode-remote.remote-ssh", // Remote SSH, After installation go to 'Preferences - User Settings' -> Extensions -> Remote - SSH -> 'Remote.SSH: Local Server Download'; Set to 'Auto'. This will make sure that the remote VSCode-Server-Linux installation is updated automatically using the local VSCode.
        // Live Share
        "ms-vsliveshare.vsliveshare", // Live share VS Code for pair programming
        // Markdown
        "yzhang.markdown-all-in-one",
        "davidanson.vscode-markdownlint", // markdown linter
        "ni.azdo-wiki-md", // enables support for Azure DevOps table of content [[_TOC_]]
        "bierner.markdown-mermaid", // enables support for mermaid diagrams
        // Misc
        "mechatroner.rainbow-csv", // Rainbow CSV
        "gruntfuggly.todo-tree", // Add TODO in code
        "alefragnani.bookmarks", // Create bookmarks in code for easy navigation
        "lukapetrovic.image-resizer", // Image resizer, right click: width[x]height 50x50 256x100 autox400 400xauto
        "hediet.vscode-drawio", // draw.io integration
        "brunnerh.insert-unicode", // Insert Unicode
        "chrisdias.vscode-opennewinstance", // Adds reopen / new workbench to folder menu
        "github.copilot", // Github CoPilot
        "oderwat.indent-rainbow", // Indent rainbow coloring
        "sonarsource.sonarlint-vscode", // Sonar linter - requires nodejs: choco install nodejs-lts
        "postman.postman-for-vscode", // Postman API tester
        "tomoki1207.pdf", // PDF viewer
        "iulian-radu-at.vscode-tasks-sidebar", // Task sidebar
        // Powershell
        "ms-vscode.powershell", // Powershell
        // Python
        "ms-python.python", // Python
        "ms-python.black-formatter", // Python formatter
        // sql
        "ms-mssql.mssql", //sql
        // Terraform
        "hashicorp.terraform", // Terraform
        // xml
        "dotjoshjohnson.xml" // xml
    ]
}

Optionally, you can add .prettierignore to the root of your project to limit prettier:

.prettierignore
# https://prettier.io/docs/en/ignore.html
# Ignore all Yaml files:
**/*.yaml
**/*.yml

Working with Files

You need a root folder to store the locally synced repository. I have some experience with both that folder on an onedrive location as well as out of it. Both work, but without oneDrive makes it less complex. So on your local drive create a folder like “repos” and then later on, place the projects below this root folder:

└── repos/
    ├── customer1/
    │   ├── repo1
    │   └── repo2
    ├── customer2/
    │   └── repo1
    └── shift/
        ├── knowledge
        ├── training
        └── work

Edit a File And Commit

After you changed a file follow these steps to have it committed back to the repository:

To stay up to date with remote repository, enable git.autofetch, which will be asked after your first commit → sync.

Changed Passwords

If, due to for example password policies, your password for TFS changes you might have to change your password on two places. The error you'll get is something like “Git fatal authentication failed for (url or team project)”

  1. The documentation states you should do a “team signout” and a “team signin”
  2. Change the password in the Windows Credential Manager as well: Control Panel –> Credential Manager –> Manage Windows Credentials –> Choose the entry of the git repository, and Edit the user and password.

Connect to Azure DevOps

Fron the Azure DevOps website, follow these steps:

Useful Links