Darren Hickling

Coding Consistently with VS Code

Published onReading time3 minutesImage sourcecongerdesign on Pixabay
Authors

VS Code has been nothing short of a revelation. Sublime Text was a brilliant evolution from Notepad++, especially the ability to install extensions from within the IDE itself. Since its introduction, however, VS Code has gone from strength to strength, is available on Windows, Linux and macOS, and continues to release genuinely useful updates every month.

As with all software platforms, however, apps are all importanttttt, and VS Code has rarely failed to provide an extension for the environment in which I code. Better yet, the extensions are often customisable via settings, and both can both shared via code! Take this example .vscode/extensions.json excerpt from my Docker repository:

{
    "recommendations": [
        "editorconfig.editorconfig",
        "ms-azuretools.vscode-docker"
    ]
}

If this repository is cloned and opened within VS Code:

# Need Git and VS Code? Install them with Chocolately on Windows...
choco install git git.install vscode

# ... or Fedora plus Snap.
dnf install git
snap install vscode

# Now clone and open the code!
git clone https://github.com/WhatIsHeDoing/DazDocker.git
code .

... the user will be greeted with a recommended extensions pop-up. If the extensions are installed — almost always a quick and painless process — they will kick into life without reloading the editor. In the case above, EditorConfig settings will be read from the accompanying .editorconfig file. The following lines:

[*]
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true

... can help prevent annoying problems with line-endings, and promote style consistency, which makes contributing to my project a little simpler. An accompanying .vscode/settings.json file is similarly readable:

{
    "editor.formatOnSave": true,
    "editor.rulers": [130]
}

As with other configuration, changes to these files can be tracked and reviewed via Pull Requests. Pair-programming also becomes a little easier: since we all use a similar base setup, it is likely that — bar a Dvorak keyboard or bizarre mouse — we can pair-code with minimal overhead.

Looking for more great extensions? The usefulness will depend on your language and frameworks, but try this fairly generic list:

You can even install these from the command line, which is useful in a Boxstarter script:

code --install-extension davidanson.vscode-markdownlint

Creating great software solutions is a complex process at the best of times, but having such a great, free IDE that can be used almost anywhere for anything removes one fairly major setup concern.