Skip to content
Aron Trauring edited this page Apr 22, 2020 · 3 revisions

How to Configure and Use Microsoft Visual Studio Code

Microsoft Visual Studio Code is a cross-platform code editor that supports many software languages using a plugin extension architecture. In many ways it’s easier to use and far more responsive than an IDE like IntelliJ. Hence it is an excellent alternative for code editing, testing and deploying.

How to Set Up Visual Studio Code

How to Configure VS Code Post-Installation

Step-by-step guide

  1. These steps are usually only necessary for your very first installation, As discussed below there is a sync extension which allows you to copy your setup up from one development machine to another. There are several things which are OS specific and those will be explicitly noted.
  2. The following is a list of extensions that are highly recommended:
Link Description
armsnippet Microsoft Azure Resource Manager (ARM) JSON Template snippets
Anaconda Microsoft Anaconda Extension Pack
Azure App Service Azure App Service
Azure CLI Tools Tools for developing and running commands of the Azure CLI
Azure Cosmos DB CosmosDB
Azure Data Lake Tools Tools for developing U-SQL projects against Microsoft Azure Data Lake
Azure Dev Spaces Azure Event Hub Management
Azure Functions Azure Functions
Azure IoT Toolkit Interact with Azure IoT Hub, IoT Device Management, IoT Hub Code Snippets
Azure Resource Manager Snippets Template language support for Azure Resource Manager JSON files
Azure Resource Manager Tools Template language support for Azure Resource Manager JSON files
Azure Storage Azure Storage
Azure Tools for VS Code Convenient features for Microsoft Azure developers
AzureAutomation Work locally, against Azure Automation subscription
C/C++ Complete C/C++ language support, including code editing and debugging
C# C# for Visual Studio Code
Code Runner Run code snippet or code file for multiple languages
Git Extension Pack Popular Visual Studio Code extensions for Git
Git History View git log, file or line History
Git Lens Visualize code authorship at a glance via Git blame annotations and code lens
GitHub Integrates Github and its workflows into VS Code
gitignore Add file to .gitignore
gitignore Language support for .gitignore files
Haskero Haskell IDE (this installs the other Haskell Plugins as dependencies
Haskell Phoityne Phoityne is a GHCi debug viewer
Haskell Syntax Highlighting Adds highlighting support for Haskell
hoogle-vscode Haskell Hoogle search
JSON Tools Tools for manipulating JSON
Jupyter Data Science with Jupyter
Kubernetes Support Code snippets for Kubernetes
macros Brings simple, powerful custom macros support to VS Code
Open in GIthub Jump to a source code line in Github / Bitbucket / Gitlab / VisualStudio.com
Project Manager Easily access and switch between Github projects
Python Linting, debugging, Intellisense, code formatting, refactoring, unit tests, snippets, Data Science, PySpark and more
Scala Language Server A Scala language server based on Ensime
Scalafmt Format Scala code using Scalafmt
Settings Sync Synchronize Settings, Snippets, Themes, File Icons, Launch, Keybindings, Workspaces and Extensions Across Multiple Machines Using GitHub Gist.
VS Team Services Connect to Team Services and Team Foundation Server and support for Team Foundation Version Control
vs-kubernetes An extension for interacting with the Kubernetes cluster orchestrator
vscode-helm Chart development tools for Kubernetes Helm
  1. Edit your Preferences -> Settings to include the following (they will be stored in the file settings.json:
    {
        "window.zoomLevel": 0,
        "editor.autoIndent": true,
        "workbench.colorTheme": "Solarized Light",
        "editor.fontFamily": "Fira Code",
        "editor.fontSize": 14,
        "editor.fontLigatures": true,
        "terminal.integrated.fontFamily": "Fira Code",
        "terminal.integrated.fontSize": 12,
        "terminal.integrated.fontLigatures": true,  
        "macros": {
            "execCurLn": [
                "expandLineSelection",
                "workbench.action.terminal.runSelectedText",
                "cancelSelection"
            ]
        }
    
  2. This is the time to set up VS Code to work with Git and GitHub. As part of this, you need to define in your settings the git binary. As noted in the instructions, that differs between Mac and Windows.
  3. Another setting that differs between Mac and Windows is the terminal integrated shell. On the Mac the default is bash, which is fine, but on Windows you have several options. Choose the one (and only one) you like. The Windows Linux Services’ Bash is a very good option, because then the experience will be most similar across OSes:
    // 64-bit cmd if available, otherwise 32-bit
    //"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\cmd.exe"
    // 64-bit PowerShell if available, otherwise 32-bit
    //"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe"
    // Git Bash
    //"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
    // Bash on Ubuntu (on Windows)
    "terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\bash.exe"
    
  4. In the settings above a macro is defined which allows you to copy code from the edit screen into the terminal. This is particularly nice for testing code snippets in the Python or Ammonite REPL. To make good use of this you can bind the macro to keys in Preferences->Keyboard Shortcuts. The definition below defines two—Ctrl-Enter for copying the text selected and `Ctrl-\``` for copying the current line. These are added to the filekeybindings.json(keybindingsMac.json` on a mac):
    [
        {
            "key": "ctrl+enter",
              "command": "workbench.action.terminal.runSelectedText",
                "when": "editorTextFocus && editorHasSelection"
        }
        {
            "key": "ctrl+enter",
              "command": "macros.execCurLn",
                "when": "editorTextFocus && !editorHasSelection"
        },
    { "key": "ctrl+`", "command": "workbench.action.terminal.focus"},
    { "key": "ctrl+`", "command": "workbench.action.focusActiveEditorGroup", "when": "terminalFocus"}
    ]
    
  5. One extension listed above that is useful for easy setting up VS code on multiple machines is the Settings Sync. This allows you to upload your settings to a private Gist and download it to other machines. If you start this process on a Mac, keep in mind you need to edit the Windows savings each time you re-sync.
  6. To start the sync, open the Command Palette (Function-F1 is quickest way to do that) and choose Sync: Update/Upload. The first time you do this it will prompt for your Github Personal Access Tokenwhich you need to create when you set up VS Code for Github. If the sync is successful it will show you the Gist ID, which you can copy and save. In subsequent update runs, if sync is successful it will show a file syncSummary.txt which summarizes what was uploaded. It also contains the Gist ID. You can also find that in the VS Settings and of course on Github.
  7. On other machines open the Command Palette and choose Sync: Download Settings. You will be prompted for the Gist ID you saved from the previous step.

Related Links

Link Description
VS Code Doco Visual Studio Code Documention