EmEditor (text editor) Forum Index
   EmEditor Core Enhancement Suggestions
     Please add the ability to swap lines
Register To Post

Flat Previous Topic | Next Topic
Poster Thread
Stefan
Posted on: 1/22/2013 8:50 pm
Home away from home
Joined: 7/14/2008
From: Germany, EU
Posts: 261
Re: Please add the ability to swap lines
.

You can extend EmEditor yourself.
Just save a macro, add to My Macros, add an shortcut.
(or use Snippet plugin)


A macro could look like:

SwapWithLineAbove.jsee

document.selection.SelectLine(); //select line with cursor
cLine = document.selection.text; //store line to var
if(cLine.indexOf("\n") < 0){cLine = cLine + "\r\n";}
document.selection.Delete();     //delete line
document.selection.LineUp();     //move cursor up one line
document.write(cLine);           //paste line from var


or

MoveLineUp_(on-and-on).jsee
(assign to Shift+Alt+U)

document.selection.SelectLine(); //select line with cursor
cLine = document.selection.text; //store line to var
if(cLine.indexOf("\n") < 0){cLine = cLine + "\r\n";}
document.selection.Delete();     //delete line
document.selection.LineUp();     //move cursor up on line
document.write(cLine);           //paste line from var
document.selection.LineUp();     //move cursor up one line


and

MoveLineDown_(on-and-on).jsee
(assign to Shift+Alt+D)

document.selection.SelectLine(); //select line with cursor
cLine = document.selection.text; //store line to var
if(cLine.indexOf("\n") < 0){cLine = cLine + "\r\n";}
document.selection.Delete();     //delete line
document.selection.LineDown();   //move cursor down one line
document.write(cLine);           //paste line from var
document.selection.LineUp();     //move cursor up one line



- - -

Swap Lines UpSideDown.jsee

FROM:
1 - x
2 - Y
3 - Z
TO:
3 - Z
2 - Y
1 - x

Sel    = document.selection.text;
SelArr = Sel.split("\r\n"); SelArr.reverse();
for(i=0,L=SelArr.length; i<L; i++){
  document.selection.text = SelArr[i];
  if(i<L-1){document.selection.text ="\r\n";}
}


.
Flat Previous Topic | Next Topic


Subject Poster Date
   Please add the ability to swap lines ArthurZ 1/22/2013 8:57 am
     Re: Please add the ability to swap lines mguttman 1/22/2013 11:53 am
       Re: Please add the ability to swap lines ArthurZ 1/22/2013 1:01 pm
       » Re: Please add the ability to swap lines Stefan 1/22/2013 8:50 pm
           Re: Please add the ability to swap lines ArthurZ 1/23/2013 5:59 am
           Re: Please add the ability to swap lines shx 1/25/2013 9:28 am
             Re: Please add the ability to swap lines ArthurZ 1/25/2013 12:25 pm
               Re: Please add the ability to swap lines TommyMills 1/27/2013 11:28 pm

Register To Post
 
English čeština Deutsch español français italiano 日本語 한국어 Русский 简体中文 繁體中文