Sublime Text 2 is a great multi-purpose text editor that you can run on Windows, MacOS and Linux. You can configure Sublime Text 2 to higlight and compile F# files and even to use F# Interactive and make it a F# REPL. Using Sublime Text 2 as F# REPL is useful when you work on MacOS and Linux (F# 3.0 works great with Mono) and cannot use Visual Studio 2012. If you are new to Sublime Text 2, check out the Perfect Workflow in Sublime Text: Free Course.

Installing necessary packages

In order to use F# Interactive in Sublime Text 2, you have to install a few packages first. All the packages can be installed using Sublime Package Control. You need to install the following packages:

  • F#
  • SublimeREPL

Configuration

The first package add F# support to Sublime Text 2 and the second one is a multipurpose REPL that can be used with many programming languages. After installing these packages, the F# REPL should immediately work if yoz have FSI in your path. Go to Tools | SublimeREPL | F# to test it out. The F# REPL always starts with its working directory set to the directory of the currently opened and selected file.

If you do not have FSI in your path, go to Preferences | Browse Packages, find SublimeREPL / Config / F, open the Main.sublime-menu file and change the path to the FSI.

Keyboard shortcut

You can configure Sublime Text 2 to run F# REPL when you invoke a shortcut like Ctrl+Alt+F (Visual Studio 2012 default shortcut for FSI) instead of going to Tools | SublimeREPL | F#. Go to Preferences | Key bindings – user and change it to

You can also configure Sublime Text 2 to set selected code to the F# REPL (Tools | SublimeREPL | Eval in REPL | Selection) when you press Ctrl+Shift+Enter just like in Visual Studio 2012 by adding

to the Preferences | Key bindings – user. All the settings files in Sublime Text 2 are JSON, so you need to paste this code into the array, just after the shortcut for F# REPL, separating them by a comma