How can I force file ordering in F# projects using vscode?

I'm trying to work with vscode in my WebSharper project (Ionide plugin seems... Whoah!) but when I load the fsproj into vscode, files in the explorer are ordered by name, not by "F# precedence". How can I configure vscode so that files are correctly ordered? Thank you.

Upvotes: 16

Views: 2414

Answers (4)

VonC
VonC

Reputation: 1324148

Without any plugin, VSCode 1.66 (March 2022) should support a better order support.

See issue 32592:

ordering of files is really important for the F# projects, and we provide couple of helper commands to manage it (move file up/down etc).
Those commands work more or less, but I don't think it's best UX.

I think it would be super nice if users had ability to use normal drag and drop to manipulate the order - just as they are able to manipulate files in normal file explorer (drag and drop files to move them to subfolder for example)

It is currently released in VSCode insider, with commit c468903 ("Finalize tree drag and drop API").

Upvotes: 0

Marcel Studer
Marcel Studer

Reputation: 591

If you have activated the great ionide plugin you can navigate to the F# symbol on the activity bar. This will open the project explorer which allows you to reorder files using the arrow icons:

Order files in project explorer

This will change the order of the files (<Compile Include="xyz.fs" /> statements) in your .fsproj file (which is what you would have to do manually if you're not using the ionide plugin).

Upvotes: 0

Krzysztof Cieslak
Krzysztof Cieslak

Reputation: 1735

The VS-like project explorer has been added to Ionide recently. It includes assembly references, project references, and ordered files (including folder supports). We've also added several commands to manipulate project and file order, you can access them with right-click context menu on this new project explorer

enter image description here

Upvotes: 2

Oleksandr Bilyk
Oleksandr Bilyk

Reputation: 87

In Visual Studio Code you press Ctrl + Shift + P, then enter "F#: Move File Up".

Upvotes: 0

Related Questions