Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #10464
    Stefan
    Participant

     

    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+"nnn";
    info += "Use "Amount-comma-direction",nn";
    info += "e.g.: "10,d" to select 10 lines downn";
    info += " or "3,u" to select 3 line up."
    alert(info);
    quit();
    }
    #10465
    Stefan
    Participant

     

    2.) GoTo and select to line X

    Purpose:
    select the lines from start line to line number X.
    Where X is a line number you entered to go to.
    Tip; Line X can be below or above current line.

    2a) EmEditor internal commands:

    To select an block:
    * set your cursor on the start of the line you want
    * press F8 to set “begin of block marker”
    * press Ctrl+G and enter the line number to go to
    (Tip: press ESC to leave selection mode)

    To select whole lines:
    * same as above but press Ctrl+F8

    To select an rectangular/vertical block:
    * set your cursor on the line and column you want
    * press Ctrl+Shift+F8 to set “begin of block marker”
    * press Ctrl+G and enter the line and column number to go to
    (Tip: press ESC to leave selection mode)

    Search the help for “F8”:

    EmEditor Help – How to – Edit
    To Select a Portion of a Document

    Click at the beginning of the selection,
    move the mouse to the end of the selection while holding
    the left mouse button down, and then release the mouse button.

    Tips
    Alternatively, press arrow keys while pressing the SHIFT key.
    Alternatively, press the F8 key, and then press arrow keys.
    To select lines, click on the left edge of the window,
    or press CTRL + F8.
    To select vertically (in a rectangular block), use the
    mouse to select while pressing the ALT key,
    or press SHIFT+ CTRL + F8.

    2b) If you want to use an script for that,
    the following code could be an start:

    To select an block:
    * set your cursor on the line you want
    * execute this script and enter the line number to go to

    o = document.selection;
    yPos = o.GetActivePointY(eePosLogical);
    TargetLine = prompt("Select to line:","");
    o.LineDown(true, (TargetLine - yPos));

    To select whole lines:
    – start at begin of line
    – at the end hold Shift-key and press End-key
    Or add this to the end of the script:
    document.selection.EndOfLine(true, eeLineLogical);

    To select an rectangular/vertical block:
    – i will post next…

    .

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.