Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #28218
    spiros
    Participant

    I often want to copy multiple different bits of texts and then paste all of them in a different file. Ideally, I would like to be able to paste all the recent strings copied, separated by an adjustable delimiter, say the pipe (|).

    For example, if I copied the bits above which were bold, I would like to be able to paste them in one go like this:

    multiple different|paste all of them|file|recent strings copied|adjustable delimiter

    Is something like this possible? Emeditor clipboard already contains the items, but there seems no way to manipulate them in the way described, ie. paste all of them (preferably with an adjustable delimiter).

    Another way would be multiple selection, but again when pasting there is no way to control the delimiter (line break is the default).

    #28219
    Yutaka Emura
    Keymaster

    You can write a macro to do this:

    
    sDelimiter = "|";  // delimiter to separate clipboard items
    
    menu = CreatePopupMenu();
    i = 0;
    do {
        str = clipboardData.getData("text", i);
        if( str.length == 0 ) break;
        str = str.substr( 0, 40 )
        menu.Add( str, i + 100 );
        i++;
    } while( 1 );
    
    result = menu.Track( 0 );
    if( result != 0 ) {
        iMax = result - 100;
        str = "";
        for( i = 0; i <= iMax; ++i ) {
            if( str.length != 0 ) {
                str += sDelimiter;
            }
            str += clipboardData.getData("text", i);
        }
        document.write( str );
    }
    

    Please see getData Method of ClipboardData:
    http://www.emeditor.org/en/macro_clipboarddata_getdata.html

    #28220
    spiros
    Participant

    Wow, interesting!
    I copied multiple items, then ran the macro, but it just displayed a pop-up with each item separated by line break.
    Maybe it would be easier to have a delimiter setting for the paste of multiple selection items? I can imagine many people could find that useful since they could use the delimiter of their choice to match their situation.

    2022-05-30-113059

    #28221
    spiros
    Participant

    Also, the paste options box (Show clipboard History on Paste), could also have the options “Paste all” (with associated hotkey), “Delete all” and in “Customize” an option could be added so that the user can set the delimiter for “Paste all”. Currently, it only has “Select all” which can be useful only if one wants to delete all (requiring 2 steps to delete).

    #28226
    Yutaka Emura
    Keymaster

    As for the delimiter in the macro, you can change the delimiter at the first line of the macro.

    #28229
    spiros
    Participant

    Yes, understood. But running the macro does not paste the text. It only produces the pop-up in the image.

    #28230
    Yutaka Emura
    Keymaster

    Did you select any item in the menu to paste the selected item and all above items?

    #28231
    spiros
    Participant

    Ah, sorry, I did not understand how they would be entered. Yes, they are entered when selected!

    I found an easier way though to automate. Use multiple selection, copy, paste, select pasted text and run a macro that replaces commas and line breaks with pipe.
    I was not sure how to trim spaces left and right of pipe so I added some extra lines for that. I was not sure either if a macro could paste directly like this after multiple selection and copy (I tried using your macro with paste after multiple copy, but it did not add the delimiter.).

    document.selection.Replace(", ","|",eeFindReplaceSelOnly | eeReplaceAll,0);
    document.selection.Replace(" |","|",eeFindReplaceSelOnly | eeReplaceAll,0);
    document.selection.Replace("| ","|",eeFindReplaceSelOnly | eeReplaceAll,0);
    document.selection.Replace("\\n","|",eeReplaceSelOnly | eeReplaceAll | eeFindReplaceRegExp,0);
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.