Using Sublime Text 2 as F# REPL

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


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

  • Pingback: F# Weekly #3, 2013 « Sergey Tihon's Blog

  • carsten

    Thanks for this blog. I have however problem with the eval part. I have installed the repl and F# packages but when I select a line from a FSI file and hit ctrl+shift+enter” then the line is not evaluated in the Fsharp interactive. Opening the F# interactive with ctrl+alt+f works fine. I am running F# 3.0 on a Mac. Any idea to what I do wrong? Thanks.

    • Igor Kulman

      The keys are different on Mac. Check out the Sublime Text docs, maybe ctrl is commad, or enter is referenced by a different name.

      • carsten

        It has nothing to done with the key combination. If I use the default setting and even just the mouse then still nothing is copied to the F# interactive.

        • Igor Kulman

          Sorry, I do not known what the problem may be and have no Mac to try it on.

  • Pingback: F# for Functional Enthusiasts Bibliography | craftyThoughts

  • Kun Ren

    Thanks for your tips. I have a problem that occurs when I use ctrl+shift+enter to evaluate the code. I set the syntax to F# and use the shortcut key, and sublime says “cannot find REPL for ‘fsharp’”. It seems that somewhere ‘fsharp’ is misused for ‘F#’. I wonder where I can fix it. Thanks!

    • igorkulman

      You need to have the F# REPL window open

      • Kun Ren

        I keep the F# REPL window open but still nothing happens when I execute the evaluation by either shortcut key or menu item. The code is simply not evaluated. There’s no error message but it still doesn’t work. What’s the problem?

        • igorkulman

          Maybe try closing every windows, quitting Sublime, then opening REPL and then trying to send some code to it. Honestly, I have no idea what may be the problem.

          • Kun Ren

            Worked once, but still doesn’t work regularly. Thanks anyway!

        • Max Galkin

          I’ve had the same, in ST3. Looks like SublimeREPL loses track of the open repl tab sometimes… I tried to close the repl tab, and re-open it (for example, via Command Palette, “SublimeREPL: F#”) and it helped…

  • Nigel Delaney

    out of curiosty, do you always tab between the editor and REPL window, or is there a nice way to put one beneath the other?

    • igorkulman

      Sublime Text offer vertical and horizontal splitting of opened tabs (View | Layout)

  • Ari

    The eval in REPL shortcut, for me, results in [Error 6] The handle is invalid. Do you have any suggestions on how to resolve the error?