Processing Ajax...

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Confirm
Close Dialog

Indent/Unindent Text

Description
Use this Macro to indent or unindent text. Use a positive value for indentSize to indent (move text to the right by 1 tab), use a negative value to unindent (move text to the left by 1 tab).
Language
C#.net
Minimum Version
Created By
Splat
Contributors
-
Date Created
Aug 19, 2014
Date Last Modified
Aug 19, 2014

Macro Code

using System;
using System.Text.RegularExpressions;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        int indentSize = 1; //Use negative or positve values
        char indentChar = '\t'; //Tab character

        if (indentSize > 0)
            text = Regex.Replace(text, @"^", new string(indentChar, indentSize), RegexOptions.Multiline);
        else if (indentSize < 0)
            text = Regex.Replace(text, @"^" + new string(indentChar, Math.Abs(indentSize)), "", RegexOptions.Multiline);

        return text;
    }
}