Community
    • Login

    How do I align/indent text to an inside column (using SHIFT-CTRL-ALT+ Left Click)

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    33 Posts 10 Posters 14.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • astrosofistaA
      astrosofista @artie-finkelstein
      last edited by

      @artie-finkelstein

      I’m not sure if I understood the example, maybe a more detailed presentation, or a video, could help me to understand the problem and eventually offer you some kind of solution.

      One preference that can affect multi-editing is Preferences -> Delimiter, so check if there are any characters added to the word delimiter.

      That’s all I can think of for now.

      artie-finkelsteinA 1 Reply Last reply Reply Quote 0
      • artie-finkelsteinA
        artie-finkelstein @astrosofista
        last edited by

        @astrosofista
        Thank you. I’m using the ‘default Word character list as it is’ setting, but that was the clue.

        I discovered that the problem only shows up if a word boundary character (i.e., non-alphanumeric and not an underscore) is present in the desired column in the Shift-End ‘expanded’ selection area. If I use a series of Ctrl-Shift-right key presses to expand the selection area to the end of column of interest AND NO FURTHER and then use a series of Ctrl-Shift-left key presses to change the selection to only the ‘undesired’ white space, it works as desired. It does not matter where the word boundary character is in the column of interest, that somehow forces a misalignment. The same misalignment occurs if there is an embedded space in the column of interest.

        Given these ‘gottchas’, I’ll stick with my brute force approach after all, as it is content insensitive. I do note that your approach is fully applicable to the OPs question as presented.

        Again, thank you for providing the key insight.

        astrosofistaA 1 Reply Last reply Reply Quote 2
        • astrosofistaA
          astrosofista @artie-finkelstein
          last edited by

          @artie-finkelstein

          You’re welcome. In case the column to be aligned has blank spaces, commas at the end of the line, or any other non-alphanumeric character, you can proceed in this other way:

          Giphy

          As we did before, make a multi-selection at the left of the USER ID column. Then

          1. Type in a space and step back pressing the Arrow Left.

          2. Press Shift + Control + Arrow Right to just select the spaces and the first words.

          3. Press Shift + Control + Arrow Left to deselect words and to select spaces.

          4. Press delete to align the USER ID column.

          That’s all.

          artie-finkelsteinA gstaviG AN ĐỗA 3 Replies Last reply Reply Quote 4
          • artie-finkelsteinA
            artie-finkelstein @astrosofista
            last edited by

            @astrosofista
            Cool. Thanks for the tip.

            It’s a shame such a powerful plugin does not have any published documentation for it’s “advanced” features. Your mini-tutorials are quite helpful, but unfortunately, I haven’t been able to discern the underlying logic to assist me in creating new solutions in future editing sessions.

            Please keep providing these tutorials, maybe something will eventually click in my head. ;)

            artie-finkelsteinA 1 Reply Last reply Reply Quote 1
            • Chris Tanguay 0C
              Chris Tanguay 0
              last edited by

              Thank you for all of this! I used the BetterMultiSelection as my first try and worked with my data, but I also am logging the Brute force way, which I’m sure will be needed on some set of data I deal with!

              1 Reply Last reply Reply Quote 0
              • artie-finkelsteinA
                artie-finkelstein @artie-finkelstein
                last edited by

                For any other users that may wish some sort of documentation on the non-obvious features of BetterMultiSelection- I found this January 2021 post by @astrosofista containing links to some of his earlier tutorials. Many are helpful, some are sublime, all seem to illustrate the secret philosophy practiced by programmers world wide: “You want comments? You want documentation? It was hard to write, it should be hard to figure out how to use it.” <grin>

                Again, thanks to @astrosofista for shedding light on it’s hidden depths. I find the ‘add a space and backup before expanding’ trick very helpful when cleaning up lists with ragged alignment. It sure beats doing it segment by segment and changing anchors as spacing changes.

                dailD 1 Reply Last reply Reply Quote 3
                • dailD
                  dail @artie-finkelstein
                  last edited by

                  @artie-finkelstein said in How do I align/indent text to an inside column (using SHIFT-CTRL-ALT+ Left Click):

                  You want comments? You want documentation? It was hard to write, it should be hard to figure out how to use it.

                  As the author of the BetterMultiSelection plugin I certainly don’t want this plugin to be ‘hard to figure out’…though I will be the first to admit that documentation is rarely fun to write :)

                  The whole purpose of this plugin (which several other editors do) is treat each cursor independently (left moves each one left, end moves each one to the end of the line, etc, etc)…and thats it. With this basic enhancement, it does certainly create some ‘hidden depths’ that even I’m not aware of. I can’t say I’ve ever seen it used this way to line up columns, but after watching the demo it makes perfect sense. Several of the other examples you linked proves I don’t know the depths that this can provide.

                  It seems I have created a hammer that I can swing; @astrosofista can use it to build a house.

                  artie-finkelsteinA 1 Reply Last reply Reply Quote 8
                  • artie-finkelsteinA
                    artie-finkelstein @dail
                    last edited by

                    @dail
                    Now that I’ve stopped laughing at your closing line: Your candor is admirable.
                    I thought I understood how BetterMultiSelection worked, exactly as you described: it ganged up the cursors (a basic feature I use every day). I had no idea that the techniques @astrosofista was demonstrating were ‘not designed in’. My comment about possibly missing documentation was based on a very incorrect assumption. I apologize if offense was received.

                    Your statement: ‘but after watching the demo it makes perfect sense’ is very beguiling. How does it make sense? Where should I look to understand the seeds that lead to the ‘a ha’ moment? (Please don’t tell me I need to grok the Scintilla source code <wry smile>, but if that’s the answer, that’s the answer.)

                    dailD 1 Reply Last reply Reply Quote 1
                    • gstaviG
                      gstavi @astrosofista
                      last edited by

                      One more optimization, using ctrl-delete. Not requiring a plugin.

                      1. Select the column to which you want to align with alt-shift-down arrow (or alt-shift-mouse).
                      2. Add ‘space’ to the entire column.
                      3. Select the space you just added with shift-alt-left arrow.
                      4. Use ctrl-delete to delete the space you added and any extra space afterward.

                      Unfortunately adding a video is beyond my abilities.

                      Alan KilbornA Chris Tanguay 0C AN ĐỗA 3 Replies Last reply Reply Quote 8
                      • Alan KilbornA
                        Alan Kilborn @gstavi
                        last edited by

                        @gstavi said in How do I align/indent text to an inside column (using SHIFT-CTRL-ALT+ Left Click):

                        One more optimization, using ctrl-delete

                        Nice one!
                        This will become my “go to technique” for this alignment operation.

                        Note that you can avoid steps 2 and 3 if you already have some whitespace to the left of your closest-to-caret “ragged” text; example (picking up after @gstavi 's step 1):

                        Imgur

                        Then, (skipping steps 2 and 3), press Ctrl+Del (step 4) to obtain:

                        Imgur

                        At that point, if you need to move the now-aligned text block to the right, simply press the space bar any number of times.

                        gstaviG 1 Reply Last reply Reply Quote 4
                        • dailD
                          dail @artie-finkelstein
                          last edited by dail

                          @artie-finkelstein said in How do I align/indent text to an inside column (using SHIFT-CTRL-ALT+ Left Click):

                          I apologize if offense was received.

                          Nope none at all :)

                          Where should I look to understand the seeds that lead to the ‘a ha’ moment? (Please don’t tell me I need to grok the Scintilla source code <wry smile>, but if that’s the answer, that’s the answer.)

                          This is beyond Scintilla, more of just problem solving with some (or more than some) trial and error. There’s no real key here but some suggestions to get your mind wrapped around better utilizing the plugin:

                          1. Just focus on one cursor at a time.
                          2. Try to solve the problem for just one line of text. (In this case the problem would be roughly “given my cursor is at a desired location, remove all whitespace after it”)
                          3. If it didn’t work in all cases, identify why (e.g. for some lines there’s no whitespace after the cursor; it deletes the first character of the non-whitespace characters)
                          4. Once you refine your assumptions (it requires at least one space…I can manually add in an extra space first), press Ctrl+Z several times and start at step #1

                          I think it’s safe to assume @astrosofista did some trial and error the first time :)

                          I think the hardest part in all this is looking at a problem and coming to the conclusion “Oh…I can (possibly) use BetterMultiSelection for this”

                          There’s been times I try to use the plugin to solve a problem…and it’s just not the right tool and I end up using regex or macros (or a combination of all 3)

                          PeterJonesP astrosofistaA artie-finkelsteinA 3 Replies Last reply Reply Quote 5
                          • PeterJonesP
                            PeterJones @dail
                            last edited by

                            @dail said in How do I align/indent text to an inside column (using SHIFT-CTRL-ALT+ Left Click):

                            Try to solve the problem for just one line of text. (In this case the problem would be roughly “given my cursor is at a desired location, remove all whitespace after it”)

                            The problem is that sometimes, my go-to solution for a single line of text doesn’t work in the column select mode. In this case, I usually use the more-keystroke-solution of Ctrl+RightArrow then Ctrl+LeftArrow – which takes you from whatever space my cursor is at to the end of the next word, then back to the beginning of that word. That same situation works in multi-select mode (Ctrl+click), but not in column-select. In the past, when I’ve had a dozen or fewer lines to do, I would Ctrl+click to start… but trying to line up more than a dozen Ctrl+click locations nearly always fails for me, so I switch to regex at that point. But now that I’ve been reminded of Ctrl+DEL’s SCI_DELWORDRIGHT behavior, I’ll see if I can train myself to use that instead.

                            1 Reply Last reply Reply Quote 0
                            • gstaviG
                              gstavi @Alan Kilborn
                              last edited by gstavi

                              @Alan-Kilborn said:

                              if you already have some whitespace

                              Sure but if you align a long column and one line is missing a space you will be deleting some word by mistake.
                              A nice thing would be to put steps 2-4 into a macro but it doesn’t work for some reason.

                              Alan KilbornA 1 Reply Last reply Reply Quote 2
                              • Alan KilbornA
                                Alan Kilborn @gstavi
                                last edited by Alan Kilborn

                                @gstavi said in How do I align/indent text to an inside column (using SHIFT-CTRL-ALT+ Left Click):

                                A nice thing would be to put steps 2-4 into a macro but it doesn’t work for some reason.

                                What seems to happen in the macro is that when step 2 is played-back it only inserts a space on the line with the main caret.

                                This is usually the bottom-most line of the zero-width column selection, but it can be the top-most line for those of us that select from higher line numbers to lower line numbers.

                                So, yea, making a macro out of it doesn’t work.

                                but if you align a long column and one line is missing a space you will be deleting some word by mistake.

                                I still like my suggestion of putting the zero-width column block somewhat to the left of the column with the closest data. Sure, you have to be careful, but you have to be careful in any text editing operation.

                                1 Reply Last reply Reply Quote 0
                                • astrosofistaA
                                  astrosofista @dail
                                  last edited by

                                  @dail, @artie-finkelstein, all :

                                  Thanks to both of you for your comments, although I think you exaggerate. And also thanks to @dail for having developed this plugin, I use it daily and am very satisfied with its performance.

                                  You are right, using this tool requires a problem-solving approach, and it certainly takes a little or quite a bit of trial and error. Especially when one gets started.

                                  However, as it happens in other cases -in regex, for example-, I think the most important thing is to look for patterns. Of course, the relevant patterns are those that can be described in the terms that the tool defines. In general, the patterns useful for regex are not the same as for the BMS plugin.

                                  This plugin recognizes two kinds of elements: words - made up of letters, numbers, and the underscore - and delimiters, lots of delimiters. It is perhaps more appropriate to focus on the latter.

                                  And unless the pattern is ultra-regular, I don’t think it’s a good idea to fixate on a single line. Rather, I think it’s best to count the delimiters on several lines in search of a regularity that can be exploited.

                                  Another feature of the plugin is that it lacks error controls. There is only visual user control. BMS does what the user requests without giving any feedback. Errors may pass unnoticed.

                                  For this very reason, and unless it is a text with a known regularity or regimented, I tend to choose the plugin -rather than regex or a script- when the text to be processed enters the screen, so I always have it under my control. Another criterion of choice, almost obvious, is that the selection can be continuous.

                                  Let’s see an example to illustrate these ideas, copied from this post:

                                  PoznamkaSlov!Prvé sväté prijímanie dňa: bez záznamu v, obci: Dolná Súča,
                                  PoznamkaSlov!Prvé sväté prijímanie dňa: 08.06.1969 v obci: Trenčín,
                                  PoznamkaSlov!Prvé sväté prijímanie dňa: 01.09.1999 v obci: Trenčín,
                                  PoznamkaSlov!Birmovaný dňa: 25.06.1972, Zapísané na RKFÚ: Soblahov
                                  PoznamkaSlov!Birmovaný dňa: 21.09.1973, Zapísané na RKFÚ: Hlohovec
                                  PoznamkaSlov!Birmovaný dňa: 17.4.2010, Zapísané na RKFÚ: Trenčín
                                  

                                  OP wanted to remove the text between the exclamation point in column 13 and the last colon, whose position varies in almost every line. There is no regular pattern of spaces, since the lines have between 5 and 7 spaces, nor is the distribution of delimiters after the colon regular. Thus, it is not possible to advance from column 13 or from the end of the line. The only interesting regularity is the exclamation point column.

                                  Another approach is needed. My first idea was to take into account a resource I mentioned in a previous message and that is to modify the word delimiter, in the preferences. If you add " ," in the corresponding field, it becomes possible to easily select the text to delete.

                                  Giphy

                                  1. Insert a multi-selection after the exclamation point column.
                                  2. Ctrl + Shift + End to select to the end of each line.
                                  3. Then Ctrl + Shift + Arrow Left to deselect up to the colon.
                                  4. Finally, delete the selected and unwanted text, pressing Back-Space.

                                  BTW, don’t forget to reset the word delimiter, or unexpected things may happen.

                                  The second idea, which came to me afterwards, turned out to be simpler - it does not require changing preferences - and is therefore better. While you can begin from the exclamation point column, for the sake of variation I’m going to start at the other end. I’m going to select column 55, that is, two characters before the colon in the last column. The idea is to remove all the unwanted characters to the right of column 55, because this creates the conditions to make a rectangular selection and easily delete the remaining text:

                                  Giphy

                                  1. Insert a multi-selection at column 55.
                                  2. Ctrl + Shift + Arrow Right to select the characters up to the colon. Repeat the action to add the colon to the selection.
                                  3. Press Back-Space to delete the selected text. We are left with a straight right margin and since the left margin is also straight, we are able to make a rectangular selection.
                                  4. Press Shift + Alt + Click after the exclamation point on the first line.
                                  5. Press Back-Space to delete the selected and unwanted text.

                                  That’s all. Hope you find this post useful.

                                  artie-finkelsteinA 1 Reply Last reply Reply Quote 6
                                  • artie-finkelsteinA
                                    artie-finkelstein @dail
                                    last edited by

                                    @dail
                                    Good suggestions, particularly about not getting hung up on all the ‘slave’ cursors, i.e., you practice playing scales before playing a concerto when learning to play the piano.

                                    I’m still trying to get caught up with all the tutorials @astrosofista posted, but this sounds like a good way to approach them.

                                    1 Reply Last reply Reply Quote 0
                                    • artie-finkelsteinA
                                      artie-finkelstein @astrosofista
                                      last edited by

                                      @astrosofista
                                      I couldn’t get your first example to work. And, I really, REALLY, don’t like the idea of changing preferences I don’t regularly modify and that seem to have a wide ranging effect on the editor configuration just to complete a single edit session. [Tab sizing is another issue and easy to verify what happens].

                                      However, the second example was right up my alley; a nice two step divide and conquer approach: take care of the irregular part then remove the remaining bulk to the left. Right along with the gist of @dail’s suggestion about not trying to view it as one big problem, instead solve the pieces.

                                      Thank you for yet another helpful tutorial.

                                      Alan KilbornA astrosofistaA 2 Replies Last reply Reply Quote 0
                                      • Alan KilbornA
                                        Alan Kilborn @artie-finkelstein
                                        last edited by

                                        @artie-finkelstein said in How do I align/indent text to an inside column (using SHIFT-CTRL-ALT+ Left Click):

                                        I really, REALLY, don’t like the idea of changing preferences I don’t regularly modify and that seem to have a wide ranging effect on the editor configuration just to complete a single edit session

                                        I find that the “palatability” of such things is proportional to how much data I’m dealing with. If it is a lot of data and the technique is going to do the job for me, it is fine. Better to mod a preference temporarily than to do a large task manually. :-)

                                        I too could not get the first example of @astrosofista to work. Here’s what it looked like after step 2, which I don’t think is correct vs. what was shown:

                                        0b5a5ec0-0f89-40a0-98a2-3b864830d7a7-image.png

                                        astrosofistaA 1 Reply Last reply Reply Quote 1
                                        • Chris Tanguay 0C
                                          Chris Tanguay 0 @gstavi
                                          last edited by

                                          @gstavi
                                          Incredible! Thank you! I’ve learned more in this one post…
                                          awesomeness

                                          1 Reply Last reply Reply Quote 0
                                          • astrosofistaA
                                            astrosofista @artie-finkelstein
                                            last edited by

                                            @artie-finkelstein, All:

                                            Sorry, my bad. There is an error in the indications of the first selection. The correct action is 2. Shift + End to select to the end of each line. Thanks for testing the example and letting me know the result.

                                            I understand if someone doesn’t want to change the preferences - as I am sometimes reluctant to change them myself - but if you want to use the multi-selection technique on a daily basis you will find that sometimes there is no other way to solve such a problem than to change the word delimiter. For example, in this post, for which I came up with that idea.

                                            Of course, and as rightly stated in the post, the problem can be solved with regex or even scripting as well. But to users like the OP of the post, who don’t know anything about regex or scripting nor sadly want to learn, they could solve the problem with the multi-selection technique, which only requires basic notions of usage like scrolling through text using the keyboard and making selections. And in some cases it requires a change in preferences. I think the benefit far outweighs the cost.

                                            Anyway, when choice is possible - which was not the case with the OP of the post -, it is reasonable for the user to choose the technique that best suits their tastes or needs. I have no objection to this.

                                            Regarding the second and last example, I would just like to comment that it is possible to solve it in either direction, i.e., one can also start with the rectangular selection and then remove the irregular part. However, for the purposes of explanation, it seemed to me that the idea is better visualized if you leave the rectangular selection to the end.

                                            That’s all. Thanks again for the feedback.

                                            artie-finkelsteinA 1 Reply Last reply Reply Quote 2
                                            • First post
                                              Last post
                                            The Community of users of the Notepad++ text editor.
                                            Powered by NodeBB | Contributors