Copy to showed lines only

This forum is user-to-user based and not regularly monitored by IDM.
Please see the note at the top of this page on how to contact IDM.

Copy to showed lines only

Postby rvrichardson » Thu Jan 17, 2013 2:55 pm

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?
rvrichardson
Newbie
 
Posts: 2
Joined: Thu Jan 17, 2013 2:40 pm

Re: Copy to showed lines only

Postby Mofi » Fri Jan 18, 2013 1:22 am

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);
}
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4049
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Copy to showed lines only

Postby rvrichardson » Fri Jan 18, 2013 9:53 am

Thank you, I'll give it a try
rvrichardson
Newbie
 
Posts: 2
Joined: Thu Jan 17, 2013 2:40 pm


Return to UltraEdit General Discussion