Tapatalk

Copy to showed lines only

Copy to showed lines only

2

    Jan 17, 2013#1

    Hello
    I am new to Ultraedit and would like to ask a question. I have a configuration test file that contains entries for 119 elements, each element contains 43 lines. I need to re sort one line out of each entry (119 in total). So I do a search and show on the line that needs to be sorted. I then copy the 119 lines into a new edit window and then sort Alphabetic/Numeric and that works perfectly. I then want to copy back the 119 lines to the first file, ignoring the hidden lines and just pasting back to the lines shown. (I have to retain the format of the configuration file, so I cannot delete the hidden lines).
    However when I paste back the 119 sorted lines, it pastes them back to the first 119 lines of the file instead of each of the 1st line of each of the elements.

    So my question is, when lines are hidden in the editor, can I force the editor to ignore those hidden lines without deleting them while I paste the sorted lines back to the original edit window?

    6,685587
    Grand MasterGrand Master
    6,685587

      Jan 18, 2013#2

      It is not possible to edit with commands like copy, paste, replace, ... just the currently displayed lines and ignoring all hidden lines.

      So you would need a script or macro to write back the sorted 119 lines in second opened file over the 119 currently showed lines in first opened file. The script below should do this job. I tested it with UE v18.20.0.1028 on 2 small files with 3 lines showed to exchange in file 1 and sorted alphabetically in file 2, and all other lines in file 1 hidden.

      Code: Select all

      if (UltraEdit.document.length > 1) {  // Are at least 2 files opened?
      
         // Set environment for the script.
         UltraEdit.insertMode();
         UltraEdit.columnModeOff();
         UltraEdit.selectClipboard(9);
      
         var DataFile = UltraEdit.document[0];
         var SortFile = UltraEdit.document[1];
      
         // Make sure that last line of the sorted lines has a line termination.
         SortFile.bottom();
         if (SortFile.isColNumGt(1)) {
            SortFile.insertLine();
            if (SortFile.isColNumGt(1)) {
               SortFile.deleteToStartOfLine();
            }
         }
      
         DataFile.top();
         SortFile.top();
      
         while (!SortFile.isEof()) {
            SortFile.selectLine();
            SortFile.copy();
            SortFile.endSelect();
            SortFile.key("HOME");
            DataFile.selectLine();
            DataFile.paste();
            DataFile.key("RIGHT ARROW");
         }
      
         UltraEdit.clearClipboard();
         UltraEdit.selectClipboard(0);
      }

      2

        Jan 18, 2013#3

        Thank you, I'll give it a try