Skip to content


Subversion checkout URL

You can clone with
Download ZIP

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.


                == F# mode for Emacs ==

   Version 0.3 - June 2010

 1) Installation

When Emacs is started up, it normally runs a file called ~/.emacs located
in your home directory. This file should contain all of your personal
customisations written as a series of Elisp commands. In order to install
the F# mode, you have to tell Emacs where to find it. This is done by
adding some commands to the init file.

Assuming you have placed the mode in your "~/.emacs.d" directory and you
now have a "~/.emacs.d/fsharp" directory, copy the following lines to your
init file (usually "~/.emacs").

(setq load-path (cons "~/.emacs.d/fsharp" load-path))
(setq auto-mode-alist (cons '("\\.fs[iylx]?$" . fsharp-mode) auto-mode-alist))
(autoload 'fsharp-mode "fsharp" "Major mode for editing F# code." t)
(autoload 'run-fsharp "inf-fsharp" "Run an inferior F# process." t)

If "fsc" and "fsi" are in your path, that's all you need. Otherwise,
you can add these two following lines to set the path to the compiler
and interactive F#.

On Windows (adapt the path if needed):

(setq inferior-fsharp-program "\"c:\\Program Files\\Microsoft F#\\v4.0\\Fsi.exe\"")
(setq fsharp-compiler "\"c:\\Program Files\\Microsoft F#\\v4.0\\Fsc.exe\"")

On Unix (adapt the path if needed):

(setq inferior-fsharp-program "mono ~/fsi.exe --readline-")
(setq fsharp-compiler "mono ~/fsc.exe")

Reload your init file or reopen Emacs. If you open a ".fs" file, the
fsharp-mode will be used automatically.

 2) Features

- Interactive F# buffer
- Indentation
- Syntax highlighter

 3) Bindings

If you are new to Emacs, you might want to use the menu (call
menu-bar-mode if you don't see it). However, it's usually faster to learn
a few useful bindings:

- C-c C-r       Evaluate region
- C-c C-e       Evaluate current toplevel phrase
- C-M-x         Evaluate current toplevel phrase
- C-M-h         Mark current toplevel phrase
- C-c C-s       Show interactive buffer
- C-c C-c       Compile with fsc
- C-c x         Run the executable
- C-c C-a       Open alternate file (.fsi or .fs)
- C-c l         Shift region to left
- C-c r         Shift region to right
- C-c <up>      Move cursor to the beginning of the block

To interrupt the interactive mode, use "C-c C-c". This is useful if your
code does an infinite loop or a very long computation.

If you want to shift the region by 2 spaces, use: M-2 C-c r

In the interactive buffer, use M-RET to send the code without
explicitly adding the ";;" thing.

  4) Contact

If you have problems using this mode, please ask on a F# forum, e.g. or

If you don't have answers, you can send me an email, I will try to reply
on the thread, as it could be useful to other people.

If you can help improving this mode, feel free to contact me! I can
give you SVN access on Sourceforge if you'd like to contribute. For
bugs and feature requests, please use Sourceforge tracker.

Contact: laurent [at]

Something went wrong with that request. Please try again.