Macro: GoTo and select... collection
1.) GoTo and select
n lines down or up/*
Just an simple script to select an exact amount of lines.
Useful e.g. to select next 1000 lines from an log to export.
Or to select always 10 header lines of an block to remove them.
Or to use with your file manager: export the list of file names,
paste them into EmEditor, use this script to select 30 lines,
copy them to the clipboard, ask your file manager
to "select from clipboard", done! ('TC' will do for example)
How-to:
First put your cursor at the begin of an line.
Then execute this script and enter the amount of lines to select
and after an comma the direction to select to: down or up.
Note: the script will check for lower case char 'd' and 'u'.
The syntax for the command is: <number><comma><d/u> like: 5,d
Or just <number> or even < -number>.
*/
//Ask the user what to do:
UserInput = "Amount of lines to select and direction, ";
UserInput += "e.g.: 10,u for 10 up, or 3,d for 3 down.";
UserInput = prompt(UserInput, "10,d");
//Check the user input:
if (UserInput == "") {quit();}
if (UserInput.indexOf(",") > -1){
CmdArray = UserInput.split(",");
cmdAmount = CmdArray[0];
if ( /^\d*$/.test(cmdAmount) == false ){funcSyntax();}
cmdDirect = CmdArray[1];
if ( /^[ud]$/.test(cmdDirect) == false ){funcSyntax();}
}else{
//simple form of user-input: just the amount of lines.
//Direction is 'd' as default:
cmdAmount = UserInput;
cmdDirect = "d";
}
//Execute the command:
if (cmdDirect == 'd')
document.selection.LineDown(true,cmdAmount);
if (cmdDirect == 'u')
document.selection.LineUp(true,cmdAmount);
//Used functions:
function funcSyntax(){
info = "error: "+UserInput+"\n\n\n";
info += "Use \"Amount-comma-direction\",\n\n";
info += "e.g.: \"10,d\" to select 10 lines down\n";
info += " or \"3,u\" to select 3 line up."
alert(info);
quit();
}