Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
fsharp-doc.el Emacs: give better error feedback Sep 10, 2014
fsharp-mode-font.el Integrating emacs faceup tests Oct 13, 2014
fsharp-mode.el Fix MSBuild detection on windows May 10, 2015



Provides support for the F# language in Emacs. Includes the following features:

  • Support for F# Interactive
  • Displays type signatures and tooltips
  • Provides syntax highlighting and indentation.
  • Intellisense support.

The following features are under development:

  • Intelligent indentation

Requires Emacs 24+ and F# 3.0. Without F# 3.0 the background compiler process will not function correctly.



fsharp-mode is available on MELPA and can be installed using the built-in package manager.

If you're not already using MELPA, add the following to your init.el:

;;; Initialize MELPA
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
(unless package-archive-contents (package-refresh-contents))

;;; Install fsharp-mode
(unless (package-installed-p 'fsharp-mode)
  (package-install 'fsharp-mode))

(require 'fsharp-mode)

Manual installation

  1. Clone this repo and run make install:

    git clone git://github.com/fsharp/fsharpbinding.git
    cd fsharpbinding/emacs
    make test-all # optional
    make install
  2. Add the following to your init.el:

    (add-to-list 'load-path "~/.emacs.d/fsharp-mode/")
    (autoload 'fsharp-mode "fsharp-mode"     "Major mode for editing F# code." t)
    (add-to-list 'auto-mode-alist '("\\.fs[iylx]?$" . fsharp-mode))

Note that if you do not use make install, which attempts to download the dependencies from MELPA for you, then you must ensure that you have installed them yourself. A list can be found in fsharp-mode-pkg.el.

If you run into any problems with installation, please check that you have Emacs 24 on your PATH using emacs --version. Note that OSX comes with Emacs 22 by default and installing a .app of Emacs 24 will not add it to your PATH. One option is:

alias emacs='/Applications/Emacs.app/Contents/MacOS/Emacs'


fsharp-mode should launch automatically whenever you open an F# buffer. When the intellisense process is running, the following features will be available:

  1. Type information for symbol at point will be displayed in the minibuffer.
  2. Errors and warnings will be automatically highlighted, with mouseover text. Jump to the next and previous error using M-n and M-p.
  3. To display a tooltip, move the cursor to a symbol and press C-c C-t (default).
  4. To jump to the definition of a symbol at point, use C-c C-d.
  5. Completion will be invoked automatically on dot, as in Visual Studio. It may be invoked manually using fsharp-ac/complete-at-point, bound by default to C-c C-..
  6. To stop the intellisense process for any reason, use C-c C-q.


fsharp-mode offers intellisense for projects using the MSBuild/.fsproj format. This allows project files to be shared with other developers using Visual Studio and Xamarin Studio/Monodevelop. To create a new project file, it is recommended that you take an existing project file and modify the list of source files. One such project file can be found in the fsharp-mode repository here.

If, on loading a new .fs file, a .fsproj file is found in the current or an enclosing directory, the intellisense process will be launched if necessary, and the project loaded. When a project file is loaded for the first time, this will be reported in the minibuffer. Projects can also be manually loaded using C-c C-p. This may be needed if a project file is in an unusual location relative to a source file, or if the project file has been modified (for example to add or remove a source file).


F# scripts (.fsx files) are standalone, and require no project file. If you wish open a script file and the intellisense process is not yet running, it will be launched automatically.


Compiler and REPL paths

The F# compiler and interpreter should be set to good defaults for your OS as long as the relevant executables can be found on your PATH or in other standard locations. If you have a non-standard setup you may need to configure these paths manually.

On Windows:

(setq inferior-fsharp-program "\"c:\\Path\To\Fsi.exe\"")
(setq fsharp-compiler "\"c:\\Path\To\Fsc.exe\"")

On Unix-like systems, you must use the --readline- flag to ensure F# Interactive will work correctly with Emacs. Typically fsi and fsc are invoked through the shell scripts fsharpi and fsharpc.

(setq inferior-fsharp-program "path/to/fsharpi --readline-")
(setq fsharp-compiler "path/to/fsharpc")


There are a few variables you can adjust to change how fsharp-mode behaves:

  • fsharp-ac-use-popup: Show tooltips using a popup at the cursor position. If set to nil, display the tooltip in a split window.

  • fsharp-doc-idle-delay: Set the time (in seconds) to wait before showing type information in the minibuffer.

  • fsharp-ac-intellisense-enabled: This mode overrides some aspects of auto-complete configuration and runs the background process automatically. Set to nil to prevent this. Note that this will only prevent the background process from being launched in the future. If it is already running you will also need to quit it using C-c C-q.

Key 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:

Key binding Description
C-c C-r Evaluate region
C-c C-f Load current buffer into toplevel
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
C-c C-p Load a project for autocompletion and tooltips
C-c C-d, M-. Jump to definition of symbol at point
C-c C-b, M-, Return to where point was before jump.
C-c C-t Request a tooltip for symbol at point
C-c C-q Quit current background compiler process
M-n Go to next error
M-p Go to previous error

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.

For key bindings that will be more familiar to users of Visual Studio, adding the following to your init.el may be a good start:

(add-hook 'fsharp-mode-hook
 (lambda ()
   (define-key fsharp-mode-map (kbd "M-RET") 'fsharp-eval-region)
   (define-key fsharp-mode-map (kbd "C-SPC") 'fsharp-ac/complete-at-point)))


fsharp-mode is still under development, so you may encounter some issues. Please report them so we can improve things! Either open an issue on Github with the label Emacs, or email the mailing list.


If you set the variable fsharp-ac-debug to a non-nil value, e.g. (setq fsharp-ac-debug 0), then some debug output will be seen in the buffer *fsharp-debug*. Setting fsharp-ac-debug to an 1 or 2 will cause a truncated or complete copy of communication between Emacs and the background intellisense process to be logged in *fsharp-debug*. This can make things rather slow, but would be useful for bug reports.

Error: F# completion process produced malformed JSON.

This is probably the result of the background intellisense process crashing and printing a stacktrace in plain text. Please report the crash, preferably with how to reproduce, and the contents of the *fsharp-complete* buffer.

Error: background intellisense process not running.

You have requested some intellisense information (such as completions or a tooltip), but the background process is not running. The most common cause of this is that a standard .fs file is being visited in the current buffer, but a .fsproj project file was not found in the same directory. Try loading one with C-c C-p.

Error: this file is not part of the loaded project.

In this case you have requested intellisense for the visited file, which is a standard .fs file not included in the current loaded project. Try loading the appropriate project with C-c C-p.

Windows completion menu performance

There are some issues with the pos-tip library used to display the documentation tooltips for completions. This can cause sluggish performance when scrolling through the list if you try to move up or down just before the tooltip is displayed. We are looking into proper solutions for this with the pos-tip maintainer. For now you can work around the issue with (setq ac-quick-help-prefer-pos-tip nil). This will use an alternative method for displaying these tooltips that is faster but uglier.

Installing from Git

If you installed by cloning the git repository and you are having problems, please sanity check by running make test-all in the emacs folder.


This project is maintained by the F# Software Foundation, with the repository hosted on GitHub.

Pull requests are welcome. Please run the test-suite with make test-all before submitting a pull request.