How to delete all spaces right of caret position in column mode to next non whitespace character on multiple lines?

How to delete all spaces right of caret position in column mode to next non whitespace character on multiple lines?

231
Basic UserBasic User
231

    Sep 26, 2017#1

    Hello!

    Does anyone know if you can delete leading spaces from the column select/cursor position, rather than the start of the line?

    What I would like to do is: use column mode, select a no-width column somewhere in my text over several lines, then delete all spaces to the right from the cursor/select position. A bit like Trim Leading Spaces, but from the select position on those lines only.

    6,603548
    Grand MasterGrand Master
    6,603548

      Sep 26, 2017#2

      You have forgotten to post the used version of UltraEdit and the used GUI mode. So I assume currently latest version UltraEdit for Window v24.20.0.30 used in ribbon mode which is not my preferred GUI mode.

      There is on ribbon tab Edit in group Select and delete an arrow below third item Delete which opens on click a popup menu with menu item Delete to start of line. This command has by default the hotkey assignment Ctrl+F11 as shown by the tooltip. The hotkey can be configured at Advanced - Settings or Configuration - Key mapping. This command is for deleting in current line everything from current position of caret to start of the line.

      In column mode after having created a no-width rectangular at a specific column, press Shift+HOME or twice Shift+HOME to select in column mode everything to column 1. Then press key DEL to delete the rectangular selection. The behavior of key HOME can be configured at Advanced - Settings or Configuration - Editor - Miscellaneous with the setting Home key always goes to column 1. Click on button Help for a description of this setting after having opened the appropriate configuration dialog.

      But there are much better methods to remove indent spaces than using column mode.

      Programmers simply select in normal text editing mode one or more lines and press Shift+TAB to decrease the indent by 1 and just TAB to increase the indent by 1. The settings at Advanced - Settings or Configuration - Editor - Word wrap / tab settings define based on file extension if the indent is done with tabs or with spaces and how many spaces represent a tab respectively an indent. See topic File extension based word wrap, tab and indent settings for details about this configuration.

      And there are on ribbon tab Format in first group Indent the two commands Indent Selection and Remove indents (two small symbols right of large Reindent Selection item) to add/remove X number of spaces from selected lines in normal text edit mode. I use never those two commands as TAB and Shift+TAB are faster to execute by key.
      Best regards from an UC/UE/UES for Windows user from Austria

      231
      Basic UserBasic User
      231

        Sep 27, 2017#3

        Thanks for your time Mofi. I possibly didn’t describe the scenario well enough.

        I have attached two screenshots that show type of text files I deal with. The first shows a column mode selection, and the second shows the result I wish to achieve, which is all leading spaces to the right of the selection deleted, so that the data lines up at the selection point.

        I am aware that I could:
        Copy the text
        Paste into a new empty file
        Use “Trim Leading Spaces”
        Copy and paste back into the original file.

        However, as I do this a lot, I’m looking for an easier method if anyone knows one.

        I have UE version 24.20.0.30.

        Delete Spaces - Start with column selection.png (48.93KiB)
        Screenshot 1 - Column selection


        Delete Spaces - Desired result.png (48.61KiB)
        Screenshot 2 - Desired result

        6,603548
        Grand MasterGrand Master
        6,603548

          Sep 28, 2017#4

          I have edited the subject as the term leading means at start of a line.

          One solution for your example is increasing with Shift+RIGHT or with pointing device the rectangular selection in column mode to have all spaces to delete selected in all lines. Then press Ctrl+R to open the Replace window. Enter as string to find a single space character, make sure the replace string is empty, select Selected text and click on button Replace all. UltraEdit removes now all spaces in rectangular selection and the numbers are left aligned the selection starting column.

          My advice on requirement to reformat text files with those data multiple times within a week or month: create an UltraEdit macro or script with regular expression replaces to reformat the data in the active file.
          Best regards from an UC/UE/UES for Windows user from Austria

          115
          Power UserPower User
          115

            Sep 28, 2017#5

            Open the Replace Window. At the bottom select the starting column (30 in example) and ending column (before the rightmost starting number in the column) to be affected by the replace. Then Find whitespace and Replace with nothing. If the change is not intended for the entire document first select the desired range and change the replace scope from entire document to selected lines. Don't forget to clear the starting and ending column fields when done.

            If you have a lot of very short numbers and other numbers starting too far to the right some spaces between the numbers column and the text column to the right may be deleted. If needed spaces are removed between the number column and the character one following it you can use one or more regular expressions to find the lines with too few spaces and replace with more spaces, once again restricting the range that is affected by selecting the columns.

            231
            Basic UserBasic User
            231

              Sep 28, 2017#6

              Interesting idea Mick, thank you for your time.