Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi all,
I have discovered that if you want syntax highlighting and automatic indenting when writing M code there is a pretty easy way without too much work.
Use fsharp-mode in Emacs.
It isn't perfect but it is pretty close.
I am sure that you could probably use a F# mode in other editors and you would get a similar affect.
Hi @Anonymous,
Can you please elaborate or provide some steps in order to do this.
Will be helpful for people who have no idea about Emacs.
Prateek Raina
Sure thing.
It is quite involved for someone who doesn't use emacs, but if you use emacs this will seem pretty straight forward.
More instructions can be found here:
https://github.com/fsharp/emacs-fsharp-mode
1) Install emacs. Now emacs is kind of a heavy duty text editor and does require a learning curve. I would suspect other text editors such as atom, Notepad++ or VS Code probably have F# syntax high-lighting as well. They would probably be easier to use.
2) In your .emacs file (which is the config file for emacs, and generally found in the home directory) you need to have code to load the melpa package managing which is something like this:
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
(not (gnutls-available-p))))
(url (concat (if no-ssl "http" "https") "://melpa.org/packages/")))
(add-to-list 'package-archives (cons "melpa" url) t))
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize)
3) Then you need to reload the .emacs file do so by M-x eval-buffer (which means press the meta key and x and then enter the command eval-buffer)
4) Then run the command (M-x package-list-packages)
5) find the pachage fsharp-mode and install this. Generally done by pressing i when the test is selected, and then press x to install.
6) Then when you have a file which contains M code in it you can run the command (M-x fsharp-mode).
Quick Addition, if you want to add melpa and install fsharp-mode at the same time, add this to your .emacs (init.el) file:
;;; Initialize MELPA (require 'package) (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/")) (unless package-archive-contents (package-refresh-contents)) (package-initialize) ;;; Install fsharp-mode (unless (package-installed-p 'fsharp-mode) (package-install 'fsharp-mode)) (require 'fsharp-mode)
Per the github repository (which has other install methods for use-package and others).
Thanks very much for the tip @Anonymous, I've never used F# so this never would have occurred to me. Finally I can halfway escape the woefully inadequate power query "advanced" editor.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
79 | |
74 | |
58 | |
36 | |
31 |
User | Count |
---|---|
91 | |
59 | |
59 | |
49 | |
42 |