上に行挿入
現在行の上に行挿入します。 Shift + Enter や Ctrl + Shift + Enter に割り当てると便利です。
#title="上に行挿入"
BeginUndoGroup();
Redraw = false;
// 以下の insertIndent のフラグを設定して、現在行のインデントを反映するかを選択してください。
// true: 現在行と同じインデントを挿入する
// false: 現在行のインデントを挿入しない
var insertIndent = true;
selection = Document.Selection;
var ay = selection.GetActivePointY(mePosLogical);
var line = Document.GetLine(Document.Selection.GetActivePointY(mePosLogical), 0);
var lineIndent = line.match(/^[ \t ]*/);
selection.StartOfLine(false, mePosLogical);
if (insertIndent) {
selection.Text = lineIndent;
}
var indentX = selection.GetActivePointX(mePosLogical);
selection.Text = '\n';
selection.SetActivePoint(mePosLogical, indentX, ay);
Redraw = true;
スポンサーリンク