Using Visual Studio Code for Ruby Development
Tags: visualstudiocode, softwaredevelopment, ruby, webdev
Published: 2017-10-01 00:07:32

---
title: "Using Visual Studio Code for Ruby Development"
published: true
tags: visual-studio-code,software-development,ruby,web-development
canonical_url: 
---

Since I have a Windows machine, I’ve been using Visual Studio Code for all my Ruby work. I had heard stories that doing Ruby development on Windows was a bit of a mission, but I thought I’d at least give it a go before shelling out some serious dollars for a&nbsp;Mac.

![](https://cdn-images-1.medium.com/max/480/0*wifgjE1hU5b7dNv3.gif)

Installing Ruby on Windows was pretty straightforward. Quick download and making sure that I could use it on my command line to run simple Ruby programs. I then wanted to get my hands on a text editor that could help me with my Ruby development efforts.

**About Visual Studio&nbsp;Code**

![](https://cdn-images-1.medium.com/max/1024/0*Tu2sJCmh_CaSOD17.png)

I’d heard about Visual Studio Code through various different place, plus I used to work for Microsoft so I’m used to their tools. Plus alternatives like Atom are quite big (300MB) compared to Visual Studio Code&nbsp;(32MB).

Code is a text editor that allows you to develop applications for Windows, Mac and Linux. It’s hosted on GitHub and it also supports extensions (I’ll talk about some Ruby specific ones&nbsp;later).

**Integrated Command Line and&nbsp;Git**

A big thing for me was to have a text editor that had a integrated command line. I don’t mind having to switch tabs all the time, I just wanted things to be lazy and&nbsp;simple.

![](https://cdn-images-1.medium.com/max/360/0*5MMest-PhnvCrUJK.gif)

The integrated terminal opens up in the root of whatever project your working on (Lazy? check!). You can also have multiple terminals open within the editor (Simple?&nbsp;check!).

Code also has built in Git support, meaning that you can track changes in your project and commit them all in one space. There’s a bunch of Git features that Code has that makes life simpler, such as viewing differences in versions and viewing the status of your repositories.

**Extensions for&nbsp;Ruby**

Code has an extensive extension library (see what I did there?….I didn’t think it was funny either). I’m currently using two extensions for Ruby. The first one is called…..[Ruby](https://github.com/rubyide/vscode-ruby) (not very interesting). This extension provides language and debugging support, such as formatting, intellisense for Ruby and debugging for&nbsp;Rails.

The second one I’m using is Ruby Language Colorization. I like things looking&nbsp;pretty.

**Example Workflow**

So let’s take it for a test drive and let’s see how easy it is to use Visual Studio Code for Ruby development. I’m going to assume you have Git, Ruby, Code etc. installed so I won’t waste time explaining all of&nbsp;that.

I’ve already set up a project in Code and initialized it with git. As you can see from the screenshot, Code already has the project root ready to go in the terminal:

![](https://cdn-images-1.medium.com/max/1024/0*F-BAJAsiP27wIOv7.png)

We can create a new file easily enough by clicking on the new file icon under the project name. I’ve created a file called example.rb and written the following code:

![](https://cdn-images-1.medium.com/max/469/0*UPxlnvG8Q2PEUIIw.png)

Simple enough code. We ask the user to enter a number to square, pass it as a parameter to our square method and then return the newly squared number back to the&nbsp;user.

Let’s run it! Instead of doing this in a separate terminal, we can use the integrated terminal within the editor like&nbsp;so:

![](https://cdn-images-1.medium.com/max/542/0*_HaJKEMwWl3F8GMV.png)

We get the following output, all shown within the&nbsp;editor:

![](https://cdn-images-1.medium.com/max/535/0*QTSVT3kPVUUGU2sO.png)

See nice and simple. We can run our program and we didn’t even need to leave the editor! Now if you have a gander towards the left hand side of the editor, you’ll notice a ‘1’ by the Git logo. Let’s have a close look at&nbsp;it:

![](https://cdn-images-1.medium.com/max/288/0*2SCUgc1fX7AK5oAt.png)

As we can see, the file is unstaged. We have two options, we can stage and commit the file using the UI, or we can do this properly in the command line. Let’s do things properly and do this through the command&nbsp;line:

![](https://cdn-images-1.medium.com/max/549/0*0LVO0SNOiTtEJckn.png)

Now have a gander at the Source Control panel, we can now see that our file has been&nbsp;staged:

![](https://cdn-images-1.medium.com/max/236/0*7phhe-eXSg_enKN_.png)

Let’s continue the&nbsp;commit:

![](https://cdn-images-1.medium.com/max/704/0*6311VVIi6W3qJtU8.png)

All done!

So we’ve created a new program, tested and ran it and pushed it to Git all without leaving the text editor itself! All bloody amazing&nbsp;stuff!

**The future**

Hopefully this blog post has shown you how Code can make life a lot easier when it comes to simple development tasks, even when dealing with non Microsoft technologies. It’s probably worthwhile to mention that I haven’t tried anything too ambitious with Code yet, such as a Rails project. When I attempt that, I’ll let you know how I get&nbsp;on.