Shift+Tab (remove indent) slow updates?

Shift+Tab (remove indent) slow updates?

2

    May 08, 2006#1

    This may have been asked before I don't know - I'm a fairly new (registered) user of ultraedit v12.00a+1.

    In various other text editors I've used over time (I'm a recent convert from crimson editor), selecting a few lines and pressing shift-tab will shift the text backwards by a tab.

    It does the same in UE, but comparatively slowly and if I've selected more lines than are displayed on the screen, you actually see the editor scroll as it moves each line back.

    This is a real pain when I'm trying to shift-tab a number of times on many lines at a time.

    Is this "just the way it is" or is there something that can be done about it?

    6,681583
    Grand MasterGrand Master
    6,681583

      May 08, 2006#2

      Yes, the SHIFT+TAB for removing preceding blanks - tabs or a specified number of indent spaces - is not as fast as adding the indent spaces. If you use it a number of times, use Format - Remove Indents. This allows you to remove the specified number of indents (tabs) at once.

      You can also switch to column mode (ALT+C), select the lines and columns (tabs), delete it and switch with ALT+C back to normal mode.

      The fastest way to remove indent tabs is a regular expression replace, which you can record in a macro. Specify SHIFT+TAB as macro hot key in the macro properties and save this macro into a macro file, which you specify as autoload. Then you can much faster remove preceding tabs. Here is the macro code for UltraEdit style regex:

      InsertMode
      ColumnModeOff
      HexOff
      UnixReOff
      IfSel
      Find RegExp "%^t"
      Replace All SelectText ""
      Else
      Find RegExp "%^t"
      Replace All ""
      EndIf

      The same macro again with Unix regex. For the Perl regular expression engine replace macro command UnixReOn by PerlReOn.

      InsertMode
      ColumnModeOff
      HexOff
      UnixReOn
      IfSel
      Find RegExp "^\t"
      Replace All SelectText ""
      Else
      Find RegExp "^\t"
      Replace All ""
      EndIf

      The macro removes with 1 run 1 tab at start of each line either on only the selected block or on the whole file.

      With the Perl regular expression engine such a macro can be used also for indent spaces.

      InsertMode
      ColumnModeOff
      HexOff
      PerlReOn
      IfSel
      Find RegExp "^ {1,x}"
      Replace All SelectText ""
      Else
      Find RegExp "^ {1,x}"
      Replace All ""
      EndIf

      For x specify the number of indent spaces you normally use for your files. The expression {1,x} means find the preceding expression (= space character) at least 1 but not more than x times. Of course the macro for tabs with the macro for indent spaces can be combined when using the Perl regular expression engine.

      InsertMode
      ColumnModeOff
      HexOff
      PerlReOn
      IfSel
      Find RegExp "^ {1,x}|\t"
      Replace All SelectText ""
      Else
      Find RegExp "^ {1,x}|\t"
      Replace All ""
      EndIf

      As you can see the search string uses now an OR expression to find either indent spaces (1 to x) or an indent tab.
      Best regards from an UC/UE/UES for Windows user from Austria

      2

        May 08, 2006#3

        Excellent, thanks!

        5
        NewbieNewbie
        5

          Jun 22, 2010#4

          Is there any reason why the internal implementation of "remove indents" could not something comparable in speed to these workarounds (or even faster)?

          It is the slowest implementation (by order of magnitude!) of all the editors supporting the feature that I worked with.

          6,681583
          Grand MasterGrand Master
          6,681583

            Jun 27, 2010#5

            alexo wrote:Is there any reason why the internal implementation of "remove indents" could not something comparable in speed to these workarounds (or even faster)?
            Yes, because the internal implementation works also for not well indented lines while the macro workarounds I posted work only for well indented lines using either tabs or spaces.

            Let us take a look on following example. » is used here as a replacement for a tab character and · as a replacement for an indenting space character.

            Code: Select all

            Line 1
            ········Indented line 2
            »       ········Indented line 3
            ················Indented line 4
            ··»     ··»     Indented line 5
            »       »       Indented line 6
            »       Indented line 7
            Line 8
            Selecting line 3 to 7 and using the third macro solution with x = 8 on this selection produces

            Code: Select all

            Line 1
            ········Indented line 2
            »       ········Indented line 3
            ········Indented line 4
            »       ··»     Indented line 5
            »       »       Indented line 6
            »       Indented line 7
            Line 8
            which is definitely not wanted. The last macro solution using tabs or spaces produces

            Code: Select all

            Line 1
            ········Indented line 2
            ········Indented line 3
            ········Indented line 4
            »       ··»     Indented line 5
            »       Indented line 6
            »       Indented line 7
            Line 8
            which is better, but still not correct. The remove indent command produces here the correct result which is

            Code: Select all

            Line 1
            ········Indented line 2
            ········Indented line 3
            ········Indented line 4
            ··»     Indented line 5
            »       Indented line 6
            »       Indented line 7
            Line 8
            Further UltraEdit supports not only 1 fixed tab stop value. Under Advanced - Configuration - Editor - Word Wrap / Tab Settings the Tab Stop value field does not allow only 1 integer number to be entered, it is also possible to enter for example 16, 12, 8, 4. This means the first tab stop is after 16 characters at column 17 (column count starting with 1 for the first column as displayed in the status bar), the second tab stop value is after 12 more characters at column 29, the third tab stop is after 8 more characters at column 37, the fourth and all following tab stops each are after 4 more characters at column 41, 45, 49, 53, ... Such a tab stop configuration is useful for editing assembler files, for editing fixed column width files (using Use spaces in place of tabs) and for viewing/editing CSV files using the tab character as separator and having always the data column widths without the need to convert the CSV file to fixed column. The Remove Indent command works for such files with different tap stop values too, but not the macro solutions.

            So the internal implementation of the remove indent command is much smarter than the quick solutions using regular expression searches which work only for well indented lines using always either tabs or spaces, but never mixed. The disadvantage of the smarter implementation is that it has to analyze the indents line by line which makes it much slower. Adding indents is much easier because at start of the line just one tab character or the correct number of spaces must be inserted without the need to analyze something. Therefore this command is much faster.

              Mar 13, 2011#6

              Performance improvements are made on the commands Format - Remove Indents (Shift+Tab) and Edit - Comment Remove in UltraEdit v17.00.

              Removing indents is now as fast as adding indents and also removing line comments works now as fast as adding line comments. Both commands are now executed without scrolling display if more lines are selected than currently displayed. For testing I added and removed indents and line comments on a 'C' file with more than 600 lines selected and all 4 commands are executed in less than 1 second.