Delete empty lines

Delete empty lines

4
NewbieNewbie
4

    Jun 29, 2009#1

    Hello

    I try to delete all empty lines in an active document. Unfortunately following script doesn't work. Can anybody tell me where is the problem?

    Code: Select all

    UltraEdit.activeDocument.findReplace.regExp=true;
    UltraEdit.activeDocument.findReplace.replaceAll=true;
    UltraEdit.activeDocument.findReplace.replace("%^p","");
    It seems that the RegExpfind string won't found. If I change the RegExp to something else, everything works fine.

    Thank's a lot for every support!

    Regards, Joerg

    6,686585
    Grand MasterGrand Master
    6,686585

      Jun 29, 2009#2

      Whenever a script uses a find or replace (regexp or normal), the (regexp) engine must be set first. Also always specify once all find/replace options. Never let your script depend on internal defaults. An internal default could change in future.

      UltraEdit.ueReOn();
      UltraEdit.activeDocument.top();
      UltraEdit.activeDocument.findReplace.mode=0;
      UltraEdit.activeDocument.findReplace.searchDown=true;
      UltraEdit.activeDocument.findReplace.searchInColumn=false;
      UltraEdit.activeDocument.findReplace.matchCase=true;
      // Not important here, but case-sensitive searches are in general faster.
      UltraEdit.activeDocument.findReplace.matchWord=false;
      UltraEdit.activeDocument.findReplace.preserveCase=false;
      UltraEdit.activeDocument.findReplace.replaceInAllOpen=false;

      UltraEdit.activeDocument.findReplace.regExp=true;
      UltraEdit.activeDocument.findReplace.replaceAll=true;
      UltraEdit.activeDocument.findReplace.replace("%[ ^t]++^p","");

      The modification in the search string results in deletion of lines containing only spaces/tabs too.
      Best regards from an UC/UE/UES for Windows user from Austria

      4
      NewbieNewbie
      4

        Jun 29, 2009#3

        Hi Mofi

        thank's a lot for your fast help.
        That's exactly what I need.

        GREAT!

        Have a nice afternoon.