複数行コメントマクロを書いた

1行コメント(//)のマクロは見つかったのだけど、複数行(/*)のは見つからなかったので、他のマクロを参考にして書いてみた。

1行コメントのショートカットを「Ctrl+Q」、複数行コメントを「Ctrl+Shit+Q」に割り当てればFlashDevelop風に!

var commentBegin = document.Config.Highlight.CommentBegin;
var commentEnd = document.Config.Highlight.CommentEnd;

Window.Redraw = false;
var startX = document.selection.GetTopPointX(eePosLogical);
var startY = document.selection.GetTopPointY(eePosLogical);
var selectionText = document.selection.Text;
var selectionTextCommentBegin = selectionText.substr(0, commentBegin.length);
var selectionTextCommentEnd = selectionText.substr(selectionText.length - commentEnd.length, commentEnd.length);
var newText;
if(selectionTextCommentBegin == commentBegin && selectionTextCommentEnd == commentEnd)
{
	//コメント削除
	newText = selectionText.substring(commentBegin.length, selectionText.length - commentEnd.length);
}
else
{
	//コメントつける
	newText = commentBegin + selectionText + commentEnd;
}
document.selection.Text = newText;
var endX = document.selection.GetTopPointX(eePosLogical);
var endY = document.selection.GetTopPointY(eePosLogical);
//再選択
document.selection.SetActivePoint(eePosLogical, startX, startY, false);
document.selection.SetActivePoint(eePosLogical, endX, endY, true);
Window.Redraw = true;

これを、ToggleBlockComment.jseeとか名前つけて保存。
動作は保証しませんがご自由にどうぞ。