Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whitespace and indentation in F#

I'm just learning about F# and plan to use it for my next project. One thing I find immediately confusing is the lack of support for tab characters in .fs files. I love how indentation is used to show scope/hierarchy, but using spaces just seems so antiquated. Do I have to press backspace four times just to get back to the parent block? What happens if I accidentally hit backspace only three times but don't notice it and keep typing?

like image 398
devios1 Avatar asked Oct 22 '10 02:10

devios1


2 Answers

If you're using VS2010, then pressing "tab" will indent four spaces, and subsequently, pressing "backspace" will also "do the right thing" for you. (I expect that some other text editors also have this feature, or at least you can configure them to do so.) If you do happen to get the wrong indent, then you're like to get error/warning squiggles as quick feedback in the VS editor.

If you're using a professional version of Visual Studio 2010, then I recommend using Column Guides from the Pro Power Tools extension. Watch this video

http://msdn.microsoft.com/en-us/fsharp/ff742849.aspx

(specifically, about two-and-a-half minutes, starting at about 2:05) to see how to use Column Guides to make F# indentation easier to discern.

like image 107
Brian Avatar answered Nov 09 '22 05:11

Brian


If there's no other option to make this easier, you can turn on visible whitespace in Studio with Control + E, Control + S.

like image 38
wsanville Avatar answered Nov 09 '22 06:11

wsanville