Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there any tool to auto tidy up F# code

Tags:

f#

Visual Studio doesn't offer automatic formatting for F#, is there any other editor I can use to automate that?

I would like it would put reasonable white spaces in between arithmetic operators (a+b) goes to (a + b) or assignment operators =

like image 440
colinfang Avatar asked Sep 07 '12 16:09

colinfang


People also ask

How do I beautify the code in Visual Studio?

The code formatting is available in Visual Studio Code through the following shortcuts: On Windows Shift + Alt + F. On Mac Shift + Option + F. On Linux Ctrl + Shift + I.

How do I auto align in Visual Studio?

Select the text you want to automatically indent.Click menu Edit → Advanced → *Format Selection, or press Ctrl + K , Ctrl + F . Format Selection applies the smart indenting rules for the language in which you are programming to the selected text. Save this answer.


2 Answers

I have been developing a source code formatter for F#. The source can be found on Github.

At the moment, a VS extension has been released in Visual Studio gallery. Integration to other IDEs and editors should be possible while the API and command line are already available.

The VS extension can handle the situations you described quite well via formatting selection feature.

like image 166
pad Avatar answered Oct 17 '22 08:10

pad


Generic code indentation is supported in FSharpMode in Emacs: Link to download site But it wont help you to do automatic white-space separation of operators, only indentation.

Maybe write a simple formatter based on Tomas Petriceks code for syntax highlighting?

Link to FSharp.Formatting

like image 21
Storstamp Avatar answered Oct 17 '22 09:10

Storstamp