The help at Microsoft Docs explains
"To run F# Interactive through Visual Studio, you can click the appropriate toolbar button labeled F# Interactive, or use the keys Ctrl+Alt+F. Doing this will open the interactive window, a tool window running an F# Interactive session. You can also select some code that you want to run in the interactive window and hit the key combination ALT+ENTER. F# Interactive starts in a tool window labeled F# Interactive. When you use this key combination, make sure that the editor window has the focus."
I am using VS2017 professional.
I have F# language support checked in the .Net desktop development work load but I cant find the F# Interactive button.
What toolbar should I be looking in for it>
You can also use the menu bar: View > Other Windows > F# Interactive.
Visual Studio has a handy quick launch bar at the top that you can use to search. F# Interactive is here:
To be honest, the "toolbar" you are looking for is actually VsCode with Ionide. :D
Related
I pressed Ctrl+Alt+F on visual studio 2017 to open F#interactive. But it doesn't interact. For example, when I typed
2+2;;
Nothing happens. I thought it would print
val it : int = 4 . But nothing gets printed. Maybe I got an error before that line and that made it not working properly? But when I close the F# interactive window using the x sign on the top right of the window and reopen it using Ctrl+Alt+F, I don't get a new window, instead I get the Window as it were when I closed it. So how should I make this work properly? Is this the right way to open F# interactive on visual studio? Here is a image:
It might be that F# Interactive is stuck somehow.
You can reset F# Interactive in Visual Studio by right clicking in the F# Interactive window and select "Reset Interactive Session" from the drop down menu.
Now in VS2013 and F#3.1.1, I noticed that it is a bit cumbersome to send code to F# interactive.
There are separate menus for but no keyboard shortcuts for
sending project output as reference to F# interactive
sending project references to F# interactive
In the editor window, there is no "send whole file" to f# interactive. You have to select it all, right click and send.
It feels very unpolished. Are any faster ways of doing this?
What are your IDE workflows?
As I am righting these questions, i think about maybe using shellplus powershell integration for invoking this...
Just in case it helps: you can right click on any reference in the Solution Explorer and do 'Send reference to interactive' - or you can right click on the References node and send them all to interactive.
You can also do this in your source:
#r #"c:\mycode\myassembly.dll"
...and you can surround that with #if interactive to stop it messing up your compiles.
#if INTERACTIVE
#r #"c:\temp\myassembly.dll"
#endif
Finally you might also want to look at script files (.fsx) - googling for "f# script files" produces some useful references.
For sending references, yes, you have to right-click on the individual reference or the references node and click "Send reference to FSI." Not perfect if you prefer keyboard shortcuts, but much improved from VS 2012 when you had no choice but to type out a full #r statement every time...
For sending code, Alt+Enter is the easiest/most popular shortcut. Highlight the code you want to execute (using either mouse or keyboard), then hit Alt+Enter. To send the entire file, just use select-all (Ctrl+A) to highlight everything.
I am interested in the ability to have F# scripting within my app.
Having something like tryfsharp.org would be great, specifically the Intellisense capability. Is any of this available on Github somewhere? How does this work?
Short answer
The code used for the first cut of TryFSharp with F# 2, which includes Intellisense support, is available as a code drop. As an example Rob Pickering built an online editor for Undertone with it. I suspect the code used on the current TryFSharp site which uses F# 3 will appear in time.
TryFSharp uses Silverlight to host the F# compiler in the client's browser (F# is written in F#). It is also possible to call an instance of the F# compiler running on the server from the browser on demand, which is an approach taken by TryFs.Net and Pit.
Longer answer
There are two sides to scripting:
Editing
Execution
F# already supports editing and execution of (.fsx) script files via F# Interactive.
Editing F# Code
There's no shortage of external editors for F# code:
Visual Studio
SharpDevelop
Xamarin Studio
Emacs
Vim
TryFSharp
F# Notebook
The editor support for Xamarin Studio, Emacs and Vim is based on the open source F# Bindings project, which provides code completion.
SharpDevelop uses the open source AvalonEdit and includes syntax highlighting for F#. You can use AvalonEdit in your own projects, for example the open source Refunctor project uses it to provide F# editing inside Reflector.
There are also a couple of new editors for F# on the horizon:
Cloud Sharper - web based F# IDE
Tsumani IDE - embedded editor for Excel, Hadoop, etc.
AvalonEdit is a good place to start for a desktop based embedded editor. Once you've chosen an editor environment then you need to choose between simple syntax highlighting or more advanced integration using F# Bindings. If you suspect people will use an external editor then syntax highlighting may be sufficient.
Bring your own editor is probably the easiest place to start which just leaves execution.
Executing F# Code
Options for executing F# code:
F# CodeDOM from the F# PowerPack
F# Compiler via the F# compiler code drop or invoking fsi.exe
Compiling a snippet with the F# CodeDOM:
open Microsoft.FSharp.Compiler.CodeDom
open System.CodeDom.Compiler
let compile snippet =
use provider = new FSharpCodeProvider()
let options = CompilerParameters(GenerateInMemory=true)
provider.CompileAssemblyFromSource(options, [|snippet|])
let snippet = """
module Snippet
let x = 1
"""
let results = compile snippet
I would like to use the F# interactive console with the projects in the currently open solution in Visual Studio 2010. Is there a quick and easy way to add a reference in the F# interactive console to reference projects in the currently open solution?
I've got lines like this at the top of my .fs file:
#if INTERACTIVE
#r #"C:\path\to\some.dll"
#I #"C:\Users\bford\path\to\a\project\in\this\solution\bin\Debug"
#r "Project.name"
#endif
Alt-Enter now drops me into fsi with all the required stuff loaded
If it's a project you reference often, you can add an 'always' reference to the FSI command line, under Tools->Options->F# Tools->F# interactive options.
Add a -r switch like:
-r "C:\Users\yaddayadda\MyDll.dll"
I don't think there is any direct way to reference a project in the solution. The best way I can think of is to add a FSX file somewhere to your project with the #r directive:
#r #"bin\Debug\YourProject.dll"
Then you can at least reference the compiled DLL file simply by hitting Alt+Enter in Visual Studio. As far as I know, you cannot reference the project - you can only reference an assembly.
Currently, F# Interactive is really disconnected from the project system in Visual Studio. I suppose that closer integration would be quite useful (but probably difficult to provide).
Now in Visual Studio 2013 you can add a reference to the F# interactive window by right clicking on the referenced dll and clicking "Send to F# interactive".
I would think it should be straightforward to reference the current project, obtain the list of references it contains, and then optionally generate a list of #r (and possibly #i) statements for the interactive session being created, referencing the dll of the project itself as well.
For example: "fsi /i:pathOfLib1 /r:lib1 /i:pathOfLib2 /r:lib2 ...."
PS: base on the MSDN article it doesn't appear that library names can include their path prefixes hence the separate into /i and /i : http://msdn.microsoft.com/en-us/library/dd233172%28v=vs.100%29.aspx
It would be good if the Visual Studio F# Interactive Options menu allowed for the stipulation of a startup script that the invocation could pass to FSI via the "--use:" directive. Such a script could then be passed solution metadata that allows for the environments to be more integrated such as loading latest project outputs.
How can I change the IDE keyboard shortcuts in Delphi?
I want to change "Run" from F9 to F5
and "Add Breakpoint" from F5 to F9
I'm currently programming Delphi at home and C# at work and these 2 shortcut keys are confusing because they are the opposites of each other!
#Kobus, you can map the keys to simulate the behavior of visual Studio IDE using the "key mappings" tab, located in tools->Editor options menu.
see theses images (Delphi 7)
Delphi 2010
Another option is install Gexperts, and use the expert IDE menu shortcuts, This expert enables you to configure any of the IDE menu shortcuts.
(source: gexperts.org)
I personally use DPack which provides a Delphi keyboard mapping for Visual Studio plus a whole range of additional tools. It's also free :-)
Simon
I've found a better solution for me because the Visual Studio emulation is not the same as my VS and can't be customised
and as Altar mentioned GExperts IDE menu shortcuts is not working with Delphi XE.
Using AutoHotkey I remap the keys using this script:
#IfWinActive, ahk_class TAppBuilder
;Set breakpoint
F5::F9
;Run
F9::F5
;Step Over
F10::F8
;Trace Into
F11::F7
;Delete line
^l::^y
;Switch between form and code
F7::F12
;Find Declaration
F12::Send !{Up}
;Navigate Back
^-::Send !{Left}
;Navigate Forward
^=::Send !{Right}
;Duplicate Line
+Enter::^!+d
;Incremental Search
^i::^e