Are there any shortcuts to move lines like Notepad++?
In Notepad++ we can move lines up or down with Ctrl+Up or Ctrl+Down.
Also, we can duplicate text/lines with Ctrl+D. This 2 feature that keeps me back to Notepad++ if I need to quick edit my pascal files.
Edit:
Solved with editor macros and assign keys to them.
Here are my editor macros to mimic the Notepad++ behavior.
duplicate line/seltext
var
s: String;
b1, b2: TPoint;
begin
with Caller do
if SelAvail then
begin
b1 := BlockBegin;
b2 := BlockEnd;
s := TextBetweenPoints[b1, b2];
TextBetweenPoints[b1, b2] := s + s;
BlockBegin := b1;
BlockEnd := b2;
end
else
begin
s := Lines[CaretY - 1];
b1.x := 1;
b1.y := CaretY;
TextBetweenPoints[b1, b1] := s + #10;
end;
end.
move line/seltext up
var
b1, b2, b3, b4: TPoint;
begin
with Caller do
begin
b1 := BlockBegin;
if b1.y = 1 then Exit;
b1.x := 1;
b2 := BlockEnd;
b2.x := Length(Lines[b2.y-1]) + 1;
b3.x := b1.x;
b3.y := b1.y - 1;
b4.y := b3.y;
b4.x := Length(Lines[b4.y-1]) + 1;
TextBetweenPoints[b3, b2] := TextBetweenPoints[b1, b2] + TextBetweenPoints[b4, b1] + TextBetweenPoints[b3, b4];
CaretY := CaretY-1;
Dec(b1.y);
Dec(b2.y);
BlockBegin:= b1;
BlockEnd:= b2;
end;
end.
move line/seltext down
var
b1, b2, b3, b4: TPoint;
begin
with Caller do
begin
b1 := BlockBegin;
b2 := BlockEnd;
BlockEnd := Point(b2.x, b2.y + 1);
b3 := BlockEnd;
if b3.y = b2.y then
begin
BlockBegin := b1;
BlockEnd := b2;
exit;
end;
b1.x := 1;
b2.x := Length(Lines[b2.y - 1]) + 1;
b3.x := 1;
b3.y := b2.y + 1;
b4.y := b3.y;
b4.x := Length(Lines[b4.y - 1]) + 1;
TextBetweenPoints[b1, b4] := TextBetweenPoints[b3, b4] + TextBetweenPoints[b2, b3] + TextBetweenPoints[b1, b2];
CaretY := CaretY + 1;
Inc(b1.y);
Inc(b2.y);
BlockBegin:= b1;
BlockEnd:= b2;
end;
end.