Collapsing tags at the same level

Collapsing tags at the same level


    Jun 16, 2014#1

    Dear Community:

    I saw this discussion thread in 2005 and would like to know: Is there a solution in the current version of UltraEdit Professional Text/HEX Editor Version I want to collapse tags that are at the same level instead of going one by one which is really disgusting/boring and tiring.

    Thanks in advanced.


    Grand MasterGrand Master

      Jun 17, 2014#2

      There is no built-in command to collapse all based on folding level in UE v21.10.0.1032 which I think would be a nice feature.

      Such a feature could be implemented with an UltraEdit script for certain languages if the active file is well indented. Here is an example for such a script quickly written because of your question.

      Code: Select all

      if (UltraEdit.document.length > 0)  // Is any file opened?
         // Define environment for this script.
         if (typeof(UltraEdit.columnModeOff) == "function") UltraEdit.columnModeOff();
         else if (typeof(UltraEdit.activeDocument.columnModeOff) == "function") UltraEdit.activeDocument.columnModeOff();
         // Remember current position of caret in the file.
         var nLine = UltraEdit.activeDocument.currentLineNum;
         var nColumn = UltraEdit.activeDocument.currentColumnNum;
         var sIndent = "";
         // Move caret to column 1 in current line.
         // Select the whitespaces at beginning of this line.
         // Nothing is selected if caret is currently on a blank line.
         if (UltraEdit.activeDocument.isSel())
            // Get the selected indent (= selected "word").
            var sIndent = UltraEdit.activeDocument.selection;
            // Is really an indent or a word selected?
            if (\S/) >= 0) sIndent = "";
         // Move caret to top of the active file.;
         // For C/C++/C# and JavaScript the open fold string is an open brace.
         var sFold = "%" + sIndent + "{";
         // Define the parameters for an UltraEdit regular expression search.
         if (typeof(UltraEdit.activeDocument.findReplace.searchInColumn) == "boolean")
         // Fold all blocks with an opening brace at current indentation level.
         // Block comments are not folded with this scripting code.
            UltraEdit.activeDocument.key("DOWN ARROW");
         // Move caret back to initial position on script start.
      Note: This script does not work for C/C++/C# or JavaScript files using styles like java attach, Kernighan & Ritchie, stroustrup, banner, linux, otbs or lisp as explained on help page with title Artistic Style Formatter dialog. Such coding styles would require a much smarter UltraEdit script.
      Best regards from an UC/UE/UES for Windows user from Austria