How to change F# Interactive newline character

ε祈祈猫儿з 提交于 2019-12-05 22:36:14

You can use conditional compilation to handle this:

#if INTERACTIVE
  text.Replace("\n", System.Environment.NewLine)
#endif

I don't know of a way to change it in fsi. Another option would be to remove, or normalize, the newlines regardless of the execution environment. If the exact length is that important, it might be good to do anyway.

EDIT

If the newlines are only there for readability, you can end each line with a backslash. The backslash, newline, and leading whitespace on the following line are removed at compile time.

let text = "a\
            b"
printfn "%s" text //"ab"

This works the same in VS and FSI. I'm assuming you're sending bits of code to FSI via Alt+Enter or Alt+'.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!