Microsoft Visual Studio Code

Microsoft released a great product named ‘Visual Studio Code’ which should not be confused as another edition of the well-known Visual Studio product line. I recently started using it and have already suggested the workplace team deploy and migrate to it for any code writing requirements. I will say that as a team we will likely still use the full Visual Studio product for any major projects to take advantage of the features it offers but for pretty much everything else VS Code is a great choice.

Now let me take a moment to give you the relevant links and a description sourced from the official site –

Visual Studio Code is a lightweight but powerful source code editor which runs on your desktop and is available for Windows, macOS and Linux. It comes with built-in support for JavaScript, TypeScript and Node.js and has a rich ecosystem of extensions for other languages (such as C++, C#, Python, PHP, Go) and runtimes (such as .NET and Unity).

Homepage – https://code.visualstudio.com/

Getting started – https://code.visualstudio.com/docs/


The installer is very small (currently around 34MB) and once completed it extracts to around 150MB on my system though I didn’t put a huge amount of effort into checking every possible location or reference. If you have ever installed the full Visual Studio product you will know it can be in the many gigabytes to easily tens of gigabytes so this is certainly ‘lightweight’ in comparison. During install you are asked if you wish to add VS Code to your PATH along with context menus as shown in the screenshot below.

Installer Setup Visual Studio Code

I chose not to enable some of these features as I have the full Visual Studio (VS) product installed already. Moving on, once installed and launched for the first time we are greeted with a homepage that is clean and simple. You will also notice the application launches much faster than full VS which can be painful when you just want to code quickly.

Visual Studio Code Homepage

To be clear – I do not intend to demo or talk about every feature of this product but I would like to highlight some features which I find useful and how I feel they benefit the team and myself when compared to some of the methods we use now.

I created a new file and as you can see below there isn’t much going on. First let me confirm that you can change the theme to suit your preferences, in this case it is a dark theme but the options are plentiful. Also note the text entries on the bottom right which when clicked on allow us to set things such as indentation, carriage return/end of line options and select a programming language.

Visual Studio Code New File Blank

By clicking on the ‘Plain Text’ words I can trigger a menu option which allows me to either scroll and select or just type and filter my language selection. As another example I can click on the ‘Spaces: 4’ option to change my indentation options.

Visual Studio Code Select Language Mode

Visual Studio Code Indentation Options

 

OK let’s move away from the lower menu area and take a look at the icons on the left side of the application window. The icons provide quick access to various features –

  • File Explorer
  • Search Function
  • GIT integration
  • Debugging
  • Extensions

Visual Studio Code File Explorer

Visual Studio Code Search

Visual Studio Code GIT

Visual Studio Code Debug

Visual Studio Code Extensions

 

As you can see there is a wide variety of extensions, you really need to see how many there are to scroll through – of course some will be more stable/feature rich than others but I would imagine whatever language you need is in there. New themes are also located in the extensions menu if you aren’t happy with the variety provided by default.

The program has auto-save functionality and can remember whatever you had open between sessions which can be really handy! I know I often find myself needing to shutdown or come off a system with lots of tabs open in the PowerShell ISE that I intend to come back to and am just too lazy to save individually.

The program settings are stored in a JSON file allowing you to customise it to whatever you desire. Note that the settings are grouped into various categories and you can search across all settings via the provided search bar.

Visual Studio Code Customise Settings JSON

C:\Users\A\Pictures\ByteSizedAlex\Microsoft Visual Studio Code\Visual Studio Code Customise Settings JSON Additionall

OK now let me write a quick snippet of code. In this instance I have a C# program, as you can see there is ‘IntelliSense’ available prompting me as I type. It is important to note I do not have any extensions installed or active, this is just the editor recognising existing text and presenting it as an option.

Visual Studio Code Programming Example C#

 

As I mentioned earlier we plan to make use of VS Code in the team and there are a few reasons –

  • Fast – when you need to code a quick function or something similar the full VS program launch etc takes too long plus we don’t want to jump between different product solutions. As an example we make extensive use of the PowerShell ISE however it is limited in certain ways and not multi-language aware so doesn’t fit our complete needs
    • VS Code will automatically add closing braces, quotes etc as you open them which is so nice when compared with ISE
  • Consistent coding
    • I want to be sure we are all using the same indentation etc
  • Free – speaks for itself, no licensing
  • Low overhead – happy to install across multiple systems without worrying about resource usage
  • Integrated terminal – you can launch a terminal/command window which is embedded in the app, in fact you can launch multiple terminals and jump between them. No need to leave and open a cmd/PowerShell prompt elsewhere

We are only just beginning the journey to VS Code and I’m sure we will find more great functionality and reasons to love it – hopefully others will too. I plan to suggest this as the standard coding tool for those of us in DevOps as well as colleagues such as DBAs. I don’t intend this to replace the full VS package our developers use but for the rest of us it’s perfect – did I mention you can get an extension for all your SQL coding needs… much awesome, such wow!

Please spread the word and check it out for yourself – I may do future posts on the product as I expand my usage or discover cool features that deserve their own article.

Leave a Reply