23

Is there any way to clear the F# interactive window in VS2010?

#cls;; and #clear;; don't work.

Quitting with #quit;; leads to the restart of F# interactive without clearing the window content.

Attempt to delete text with "delete" or "backspace" gives an error message that the text is read-only.

Alexander Galkin
  • 12,086
  • 12
  • 63
  • 115
  • 5
    Is there any problem with Right mouse click -> `Clear All`? – pad Feb 10 '12 at 13:29
  • @pad The only problem is that I didn't find it on my own. Strangely, I couldn't find it by decent googling either -- hence started a thread here. – Alexander Galkin Feb 10 '12 at 13:33
  • The answer is that there is no directive in `fsi` to do so. But Visual Studio offers a context menu to help in this case. Alternatively, if you use `Reset Session` menu, F# Interactive console is also cleared. – pad Feb 10 '12 at 13:35
  • @pad Actually it is a pity, because I use `fsi` for debugging and use verbose logging in my F# code -- it would be helpful to be able to delete the content programmatically from script. But I failed to find even the context menu trick while googling for this issue. – Alexander Galkin Feb 10 '12 at 14:39
  • 1
    If you want to get rid of annoying declaration, this thread http://stackoverflow.com/questions/2971685/f-keep-f-interactive-from-posting-output could be helpful. – pad Feb 10 '12 at 14:48

5 Answers5

19

Clear All

. Right Click and Clear All.

swapneel
  • 3,061
  • 1
  • 25
  • 32
12

If you are inside of VS F# Interactive window, you can use right mouse click and select

Clear All

Unfortunately this will now work in stand alone console FSI window. So what you can do is to following command in your console FSI window

System.Console.Clear();;
Vlad Bezden
  • 83,883
  • 25
  • 248
  • 179
3

Would printing 30 newlines get what you want? Just throwing out an idea.

Brian
  • 117,631
  • 17
  • 236
  • 300
  • That's actually not a bad idea Brian. I mean I know what he's asking about and there are times when I'd like a "#clear;;" in FSI myself. :-) – Onorio Catenacci Feb 10 '12 at 18:13
  • 11
    @OnorioCatenacci: in fsi.exe, `System.Console.Clear();;` works. – kkm inactive - support strike Feb 11 '12 at 09:07
  • 3
    In VS2012, System.Console.Clear() gives me this error: System.IO.IOException: The handle is invalid. – Gustavo Guerra Jan 20 '14 at 14:57
  • @Brian LOL LOL - even though System.Console is prob the right choice, i will now always start my fsi with a function that does the 30 newlines - that's thinking outside the bun.. and then you can more easily ref your past methods if you decide to keep, so..... +1 – schmoopy May 21 '14 at 01:30
1

In VS 2022, you can simply press this, hopefully works on all versions

CTRL + ALT + C
0

Thanks, for the hint. I do rapid prototyping for compiled programs with f# and have the need as well quite often. Now that leads me to paste a function at the start of a session:

let cls = System.Console.Clear();;
Adil B
  • 14,635
  • 11
  • 60
  • 78
Alex
  • 1
  • didn't work as expected but; just for fun: type blank()= member this.cls() = System.Console.Clear();; invoke in fsi with blank().cls();; – Alex Oct 10 '18 at 16:35