selectedLines = textArea.getSelectedLines();
for(i = 0; i < selectedLines.length; ++i)
{
    offsetBOL = textArea.getLineStartOffset(selectedLines[i]);
    textArea.setCaretPosition(offsetBOL);
    textArea.goToStartOfWhiteSpace(false);
    textArea.goToEndOfWhiteSpace(true);
    text = textArea.getSelectedText();
    if(text == null) text = "";

    if (text.startsWith("# ")) {
        text = text.substring(2);
    }

    textArea.setSelectedText(text);
}        
