It’s F# Advent time again! This is a yearly event the F# community comes together for the month of December and each person releases an F# related post on a day of their choosing. Today is that day for me this year.

With the recent announcement at Microsoft’s Connect() conference, Visual Studio Code now has an awesome update that can install extensions. With me being an F# fanatic I got excited to see that actually using F# is one of the first extensions available via Ionide which is originally made for developing in F# in GitHub’s Atom client.

While you could technically already “use” F# in Visual Studio Code, it was only for syntax highlighting. You couldn’t run any of the code. This quick post will help show you the steps to started developing F# within Visual Studio code.

The original creator of Ionide, Krzysztof Cieślak, did a great guest post for the .NET Blog to help announce F# support for VS Code. I figured I’d do my best to extend on it with this post.

Installing the F# Extensions

If you’re used to Atom or Sublime you’re already familiar with the command palette in Visual Studio Code (scroll down to the Command Pallete section). If not, just hit Cmd+P for the Mac version..

In here, just type in ext install f# and you’ll get a list of available F# extensions. The first one is for FAKE (which we have a few posts detailing some uses) and the second one is the main F# extension we’ll use.

Install Extension

The next one that you’d want to install is Paket. Think of this as NuGet on steroids. Once these are all installed go ahead and restart VS Code to use them.

Using the F# Interactive (FSI)

Now that the extension is installed, you can now create .fs or .fsx files in Visual Studio Code and execute the code in there in the F# interactive.

First, to launch the FSI, go back to the command palette and enter >fsi start. This will launch another split window with the FSI.

FSI

And, of course, we now have intellisense for F#.

F# Intellisense

In all of your F# code, you can send directly to the interactive window. I’m using >fsi send selection in the command palette here to send the highlighted selection to the FSI.

Send to Interactive

Although, at the time of this writing, you can’t type directly into the interactive window.


Of course, this is just the very beginning of what can be done with VS Code with F# as more and more features will be supported in Ionide. Look for more posts on all of those here. This is a great beginning for F# cross-platform development and I can’t wait to see where all of this goes.

  • Pingback: Dew Drop – December 9, 2015 (#2148) | Morning Dew()

  • CN Romaine

    In case you get this error “Running the contributed command:’fsi.SendSelection’ failed”, you will have to include the PATH to fsi.exe in your PATHs. Read [link](https://github.com/ionide/ionide-vscode-fsharp/issues/4) for information.

  • CN Romaine

    In case you get this error “Running the contributed command:’fsi.SendSelection’ failed”, you will have to include the PATH to fsi.exe in your PATHs. Read [link](https://github.com/ionide/ionide-vscode-fsharp/issues/4 ) for information.

  • Pingback: The week in .NET – 12/15/2015-IT大道()

  • Stewart Robertson

    Nice blog. I have been trying to work out how you managed to get the FSI/Output window in ‘side-by-side’ mode in VS Code? It only seems to appear below for me. I’ve tried everything I can think, looked for a config setting, and even asked the good folks at stack overflow (http://stackoverflow.com/q/36702207/2455494) but drew a complete blank. What am I missing?

  • Stewart Robertson

    Nice blog. I have been trying to work out how you managed to get the FSI/Output window in ‘side-by-side’ mode in VS Code? It only seems to appear below for me. I’ve tried everything I can think, looked for a config setting, and even asked the good folks at stack overflow (http://stackoverflow.com/q/36702207/2455494) but drew a complete blank. What am I missing?

    • Jon

      The comment in your StackOverflow may be correct. I was using VS Code for this post *right* when it was announced that they included extensions in it. Unfortunately, I haven’t played around with it much lately and it could have changed. If I find anything, though, I’ll let you know!