MarsEdit Script: Indent Right

MarsEdit doesn’t have an “Indent Right” command. However, inserting a tab before each line is how to represent code in Markdown. So I wrote a script to make it easier:

tell application "MarsEdit"
    set input to selected text in document 1

    set output to ""
    repeat with inputLine in (paragraphs of input)
        set output to output & (ASCII character 9) & inputLine & (ASCII character 13)
    end repeat

    set (selected text in document 1) to output
end tell

Nicely recursive: I just used the above script to indent the above script.

Though instead of putting it into ~/Library/Application Support/MarsEdit/Scripts, I put it into ~/Library/Scripts/Applications/MarsEdit/Indent Right.scpt where I bind it to ⌘] in FastScripts.

Ahh, just like BBEdit and Xcode…

marsedit applescript Nov 4 2009