Edit: Indentation buttons are now available as a user-script on Stack Apps.
I maded my own buttons now. Currently they reside in my bookmarks toolbar:
And they link somewhere nice, the left one for example:
javascript:var%20tb%20=%20document.getElementById("wmd-input");...
In Firefox and Chrome (the only ones I tested) you can just bookmark scripts, and they nicely convert all the whitespace. Here are the full scripts, nothing special really:
//Indentation Up
var tb = document.getElementById("wmd-input");
var text = tb.value.substring(tb.selectionStart, tb.selectionEnd);
var lines = text.split("\n");
var shift = 0;
for (var i = 0; i < lines.length; i++)
{
lines[i] = " " + lines[i];
shift += 4;
}
replaceSelection(tb, lines.join("\n"));
void (0);
function replaceSelection(textbox, text)
{
var selectionStart = textbox.selectionStart;
textbox.value = textbox.value.substring(0, textbox.selectionStart) + text + textbox.value.substring(textbox.selectionEnd);
textbox.selectionStart = selectionStart;
textbox.selectionEnd = selectionStart + text.length;
}
//Indentation Down
var tb = document.getElementById("wmd-input");
var text = tb.value.substring(tb.selectionStart, tb.selectionEnd);
var lines = text.split("\n");
var shift = 0;
for (var i = 0; i < lines.length; i++)
{
if (lines[i].substring(0, 4) == " ")
{
lines[i] = lines[i].substring(4);
shift += 4;
}
if (lines[i].charCodeAt(0) == 9)
{
lines[i] = lines[i].substring(1);
shift++;
}
}
replaceSelection(tb, lines.join("\n"));
void (0);
function replaceSelection(textbox, text)
{
var selectionStart = textbox.selectionStart;
textbox.value = textbox.value.substring(0, textbox.selectionStart) + text + textbox.value.substring(textbox.selectionEnd);
textbox.selectionStart = selectionStart;
textbox.selectionEnd = selectionStart + text.length;
}
Note that the preview will not update after the script has been executed. Some calls which would do that could be included I suppose.
(I am aware that the code is redundant, I just did it this way for simplicity.)