//重複行を削除するマクロ //選択範囲を指定していなければ全文を選択する if (document.selection.Text == "") document.selection.SelectAll(); var tx = document.selection.Text; tx = tx + "\n"; //選択範囲の末尾に改行を追加 tx = tx.replace(/^(.*\n)\1+/mg, "$1"); //同じ内容の行が二つ以上あればひとつだけ残す // tx = tx.replace(/^(.*\n)\1+/mg, ""); //同じ内容の行が二つ以上あるものは削除する document.selection.Text = tx; //選択した文字列と入れ替える //キャレットを選択範囲の先頭に移動(無効化するとキャレットは選択範囲の末尾に居座る) document.selection.StartOfDocument();