Home
Options

Tabs are converted to spaces (even though configured not to)

I'm running Linqpad v5.43 and I do a simple Console.WriteLine("\t") and my output is converted to 2 spaces? My Linqpad is converted to NOT convert tabs to spaces.

Comments

  • Options

    The option in LINQPad that controls whether tabs are converted to spaces applies only to the editor.

    With the results panel, output is rendered as HTML which doesn't normally render tabs except as ordinary spaces.

  • Options

    Would it be possible to get an option to change it from the current two spaces? Maybe output (configured value - 1) nbsp's and a regular space instead of one nbsp and a space like it's doing now. I cannot read two space indenting.

  • Options
    edited February 2021

    Have you tried PanelManager.DisplaySyntaxColoredText? This displays text using the same logic as a code editor, which ensures that tabs are processed correctly, and also optionally syntax-highlights it:

    PanelManager.DisplaySyntaxColoredText ("*\t**\t***\t****", SyntaxLanguageStyle.None);

    This method displays the output in a separate tab. If you want it in the main results tab, your easiest option is to write an extension method that utilizes HTML's pre tag:

    void Main()
    {
        "*\t**\t***\t****".Pre().Dump();    
        "*\t**\t***\t****".Pre().Dump("heading");
        new {
            Plain = "test",
            Formatted1 = "*\t*".Pre(),
            Formatted2 = "line 1\n\tline 2".Pre()
        }.Dump();
    }
    
    public static class Extensions
    {
        public static LINQPad.Controls.Control Pre (this string data)
        {
            return new LINQPad.Controls.Control ("pre", data);
        }
    }
    

    If you define the extension method in the "My Extensions" query, you'll be able to call it from any query.

  • Options

    Thank you, I've added that.

    It would still be nice, though, to just be able to set a default behavior and not be something extra I have to call every time. If at all possible.

Sign In or Register to comment.