Community
    • Login

    [New plugin] Columns++

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    69 Posts 9 Posters 16.5k 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.
    • CoisesC
      Coises
      last edited by

      I’ve created a new plugin, Columns++, for Notepad++.

      Key features are:

      • Elastic tabstops: Columns++ includes a new implementation of Nick Gravgaard’s Elastic tabstops.
      • Find and replace in rectangular selections
      • Calculations: There are commands to add or average numbers in one or more columns.
      • Alignment: You can left- or right-align text, or line up numbers.
      • Sorting: Columns++ includes sort commands that work correctly with rectangular selections in files that use tabs.

      It’s on GitHub and there is a help file.

      For now, it’s “use at your own risk,” since no one but me has tried it yet. To install it, the release zips must be unzipped to a folder named ColumnsPlusPlus, which must be copied into the plugins directory in your Notepad++ installation.

      Thanks for any feedback. There are features I would like to add, but seemed time to get this thing out into the wild.

      Lycan ThropeL Alan KilbornA Pete RunP 3 Replies Last reply Reply Quote 9
      • Lycan ThropeL
        Lycan Thrope @Coises
        last edited by Lycan Thrope

        @Coises ,
        Will have to play with this. I saw it “kind” of work on a Do Case/Endcase structure, but it was inconsistent on what it would or would not work on.
        For instance, the one Case construct, it moved the line from a previous construct, but only immediately above it, and it also moved the code that was part of it’s own line under it, but none of the other Case aligned sections moved with it.
        I really need to learn how to use this OBS Studio to record this stuff, so I can show it rather than textually describe it.
        Anyhow, I was curious what this plugin that others have talked about, was about, and was pleased to read the links you showed to see how it was supposed to work, and try your version. If I can be of help to find any other issues, I’ll be sure to mention them.
        Regardless, thanks for contributing to the continued expansion of the capabilities of NPP.

        Alan KilbornA CoisesC 2 Replies Last reply Reply Quote 0
        • Alan KilbornA
          Alan Kilborn @Coises
          last edited by

          @Coises

          To kick things off for you, I put in an ISSUE against your plugin. :-)

          I’ll have more to say in upcoming posts in this thread…

          CoisesC 1 Reply Last reply Reply Quote 0
          • Alan KilbornA
            Alan Kilborn @Lycan Thrope
            last edited by

            @Lycan-Thrope said in [New plugin] Columns++:

            I really need to learn how to use this OBS Studio to record this stuff, so I can show it rather than textually describe it.

            Certainly even some simple static screenshots would augment the textual descriptions…

            1 Reply Last reply Reply Quote 0
            • CoisesC
              Coises @Alan Kilborn
              last edited by

              @Alan-Kilborn Thank you, Alan. I can’t reproduce that behavior here… I know where the problem must lie, I just don’t know why it would be different on some systems than others. I posted a new release, v0.0.1.2-alpha, with a change to clear the background more “aggressively.” When you have a chance, let me know if this makes a difference.

              1 Reply Last reply Reply Quote 1
              • CoisesC
                Coises @Lycan Thrope
                last edited by

                @Lycan-Thrope Based on your description, I assume you’re talking about the Elastic tabstops function.

                I would like to suggest something. Try selecting the “Profile…” option just under “Elastic tabstops”; in the dialog, choose “General” from the drop-down box at the top, then click “OK” at the bottom.

                It is possible that doing that will make it behave more as you expect. The setting is retained; you won’t have to do it repeatedly.

                Alan KilbornA Lycan ThropeL 2 Replies Last reply Reply Quote 1
                • Bas de ReuverB
                  Bas de Reuver
                  last edited by

                  Sounds like an interesting plug-in, but tbh it’s unclear to me how to use it. I assume it only works with tab-separated or fixed width files, so not comma or semicolon separated data?

                  At first I clicked Sort ascending (numeric) assuming that it would base the column on the current cursor position, but nothing happened. After a while I figured out that you first have to column-select part of the data file, and then select the “Sort ascending” option from the plugin menu. Maybe add a popup warning message when the user clicks a menu item but no column-selection was made.

                  It looks promising, but I think the github main page should make clear which type of data files are supported and maybe add a screenshot explaining some of the functions.

                  CoisesC 3 Replies Last reply Reply Quote 0
                  • Alan KilbornA
                    Alan Kilborn @Coises
                    last edited by Alan Kilborn

                    @Coises

                    For me, the star attraction of your plugin is the Search feature. The other features don’t hold much interest to me. I’m sure they will to others, though.

                    Notepad++ has long lacked a search-only-in-column-block feature, so it is nice to see it in a plugin.

                    I created a scripted solution for replace-all in a column block some time ago (HERE), but probably the “barrier to entry” for a scripted solution is higher for a lot of folks than a plugin. Both types of solution require a plugin, but a lot of people get weak in the knees when doing anything relating to programming (even if you’re not asking them to program at all, just to run some code that is prewritten).


                    So I created some text:

                    Bar street between single.
                    Above remember; yes lake.
                    Appear watch company here pose hope.
                    Supply, busy will problem reason evening broad condition truck.
                    Thank spring lie in country!
                    327 Planes low cause world wire.
                    Student final quotient syllable captain.
                    Dear question wind, ran.
                    Compare differ vary back; star; draw, young open, brown.
                    40 Banks fair form magnet unit own.
                    Win quart dark women.
                    Here sure fine seven winter next, after, operate.
                    Equate better clear, hurry!
                    

                    And I marked it thusly:

                    9460e82c-70f1-4d82-bb66-d79fcca6fa15-image.png

                    And then I set this up:

                    cd5c7ebb-12de-43ac-9469-a9a4658da733-image.png

                    And I attempted to “walk through” and replace, using only the Replace button (I pressed nothing else, no did anything else in between presses).

                    And…it didn’t hit all of my e characters from the starting column block selection. Maybe try my example and see what you think.

                    CoisesC Alan KilbornA 2 Replies Last reply Reply Quote 0
                    • CoisesC
                      Coises @Alan Kilborn
                      last edited by

                      @Alan-Kilborn said in [New plugin] Columns++:

                      Maybe try my example and see what you think.

                      Ah… yes.

                      For what it’s worth, if you used “Backward direction” (except with regular expressions) or “Replace All” you would get the results you expected.

                      Behind the scenes, when you restart a search from the current position, Columns++ restores the original selection — meaning a rectangular selection that starts and ends at the same physical positions on the same lines (counting forward from the front to find the top line and backward from the end to find the bottom line) as the original — before it searches again. When you replace text with new text of a different length, preexisting text moves into or out of the selection.

                      While that made sense to me at the time, now that you’ve given this example, I realize it’s counter-intuitive. People will expect the “selection” to contain the same text, not the same rectangular block.

                      I’ll think about how to do this better. What makes it complicated is that I wanted to leave it open that someone might edit text before resuming, and then… what’s “the same” selection? Restoring the same “physical” rectangle seemed reasonable. I would like to avoid having to catch every single edit and update pointers according to where it occurs (because that feels both heavy and fragile), but that might be the only way to behave as expected.

                      Thank you for the observation.

                      1 Reply Last reply Reply Quote 1
                      • CoisesC
                        Coises @Bas de Reuver
                        last edited by

                        @Bas-de-Reuver said in [New plugin] Columns++:

                        Sounds like an interesting plug-in, but tbh it’s unclear to me how to use it. I assume it only works with tab-separated or fixed width files, so not comma or semicolon separated data?

                        Correct. One of the features I hope to add at some point is conversion between tab-separated and comma-separated values files. The column-oriented functions aren’t really useful unless the file is visibly organized into columns, and as far as I know there is no way in Scintilla, the text edit and display engine used by Notepad++, to position text arbitrarily on a line except using tab stops.

                        At first I clicked Sort ascending (numeric) assuming that it would base the column on the current cursor position, but nothing happened. After a while I figured out that you first have to column-select part of the data file, and then select the “Sort ascending” option from the plugin menu. Maybe add a popup warning message when the user clicks a menu item but no column-selection was made.

                        I see your point. When there’s no selection, it just does nothing, which is confusing.

                        You can select a span of text on a single line, and Columns++ will take that as an implied selection of the same columns all the way to the end of the file (see here, starting with the fourth paragraph). Based on your observation, I’m thinking I’ll add a pop-up box proposing a reasonable selection when the command would otherwise do nothing; for example, when there is no selection, “This command requires a rectangular selection. Would you like to select from the cursor to the bottom right of the document? Yes/No”

                        It looks promising, but I think the github main page should make clear which type of data files are supported and maybe add a screenshot explaining some of the functions.

                        I’ll think about what I can add to make it more clear. Thank you for your comments.

                        Bas de ReuverB 1 Reply Last reply Reply Quote 1
                        • Mark OlsonM
                          Mark Olson
                          last edited by

                          One change I would consider making to the Add Numbers and Average Numbers commands is to make it very clear that the command copies the result to the clipboard. Some users will probably be unhappy that you overwrote their clipboard data without telling them that that’s what you were going to do.

                          OTOH, stating that clearly would result in some more cumbersome verbiage that lacks the nice simplicity of the current command names.

                          Alan KilbornA CoisesC 3 Replies Last reply Reply Quote 1
                          • Alan KilbornA
                            Alan Kilborn @Mark Olson
                            last edited by

                            @Mark-Olson said in [New plugin] Columns++:

                            Add Numbers and Average Numbers commands is to make it very clear that the command copies the result to the clipboard

                            Currently it pops up a box with the result; perhaps having this box have 2 buttons, “OK” and “Copy”, would be an acceptable way around doing an automatic (and perhaps unwanted) copy.

                            1 Reply Last reply Reply Quote 0
                            • Bas de ReuverB
                              Bas de Reuver @Coises
                              last edited by

                              @Coises said in [New plugin] Columns++:

                              One of the features I hope to add at some point is conversion between tab-separated and comma-separated values files.

                              fyi that is something my CSV Lint plug-in can also do

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

                                @Alan-Kilborn said in [New plugin] Columns++:

                                And…it didn’t hit all of my e characters from the starting column block selection.

                                I was eating dinner and I had the horrible thought: What if my script solution I pointed out before did the same behavior I complained about earlier? I would have had to have a nice dessert of humble pie. :-)

                                Thankfully, the script didn’t:

                                4c2fa20e-2ca2-4d31-b7ec-faf841c50bc8-image.png

                                But yes, from the screenshot, the blocking is no longer a nice simple rectangular block.

                                1 Reply Last reply Reply Quote 0
                                • Alan KilbornA
                                  Alan Kilborn
                                  last edited by Alan Kilborn

                                  Also, I felt a bit “uncomfortable” doing a bunch of Find Next s through a column-block that I could no longer see. I felt much better doing it after redmarking the block:

                                  16be2de0-3eda-4975-881a-e59545f20aea-image.png

                                  using this PythonScript, which I called RedmarkAllSelections.py:

                                  # -*- coding: utf-8 -*-
                                  
                                  from Npp import *
                                  
                                  #-------------------------------------------------------------------------------
                                  
                                  class RAS(object):
                                  
                                      def __init__(self):
                                  
                                          self.SCE_UNIVERSAL_FOUND_STYLE = 31
                                          self.redmark_clear_range(0, editor.getLength())
                                          for n in range(editor.getSelections()):
                                              s = editor.getSelectionNStart(n)
                                              e = editor.getSelectionNEnd(n)
                                              self.redmark_fill_range(s, e)
                                  
                                      def redmark_clear_range(self, start_pos, end_pos):
                                          editor.setIndicatorCurrent(self.SCE_UNIVERSAL_FOUND_STYLE)
                                          editor.indicatorClearRange(start_pos, end_pos - start_pos)
                                  
                                      def redmark_fill_range(self, start_pos, end_pos):
                                          editor.setIndicatorCurrent(self.SCE_UNIVERSAL_FOUND_STYLE)
                                          editor.indicatorFillRange(start_pos, end_pos - start_pos)
                                  
                                  #-------------------------------------------------------------------------------
                                  
                                  if __name__ == '__main__': RAS()
                                  

                                  It’s a bit subtle, but I could see the selected hit text “beneath” the redmarking:

                                  7fba3c2f-76de-4aa6-b21a-4def3ca06071-image.png

                                  I don’t know…I just felt better being able to see the “bounds” of the block I was searching in, during the selecting of each hit after each Find Next press.

                                  CoisesC 2 Replies Last reply Reply Quote 1
                                  • CoisesC
                                    Coises @Alan Kilborn
                                    last edited by Coises

                                    @Alan-Kilborn Well, that’s interesting. I did not know about “marking” blocks of text. Is this something that would interfere with other ways people use this feature (if Notepad++ exposes it at all) if I were to mark the block upon the first search, and leave it marked until either the user makes a new selection, or the dialog is closed?

                                    Alan KilbornA 1 Reply Last reply Reply Quote 1
                                    • Lycan ThropeL
                                      Lycan Thrope @Coises
                                      last edited by

                                      @Coises ,
                                      Yeah, I tried that, but it didn’t seem to work either.
                                      I’m going to admit, It looks good in the animation, but I really don’t understand what it’s supposed to be doing and how. Like @Alan-Kilborn mentions, I can see value in the sort selection aspect also, but for now, I think I’ll just have to chew on figuring out and reading the documentation…more closely to figure out what I’m supposed to be doing.
                                      :-)

                                      1 Reply Last reply Reply Quote 0
                                      • Alan KilbornA
                                        Alan Kilborn @Coises
                                        last edited by

                                        @Coises said in [New plugin] Columns++:

                                        I did not know about “marking” blocks of text.

                                        At a user level, the general marking feature is on the Mark tab of the Find family of windows, invoked by Ctrl+m by default. A similar but less powerful user-level feature to get different colors onto literal text is at Search menu > Style …

                                        The Scintilla feature controlling both is called indicators.

                                        Is this something that would interfere with other ways people use this feature (if Notepad++ exposes it at all) if I were to mark the block upon the first search, and leave it marked until either the user makes a new selection, or the dialog is closed?

                                        If I were you, I’d consider allocating a new indicator exclusively for your plugin’s use for this purpose, if you like the general idea. Going that route, you wouldn’t have to be concerned about “interference”.


                                        By the way, I had an admittedly brief look at your source code for the plugin, and it looks excellent; nice job.

                                        Your help html file is also a joy to look at; other programs could use such a concise and well-written help file as a model. I’m curious what tool you might have used to assist in producing this?

                                        CoisesC 1 Reply Last reply Reply Quote 5
                                        • CoisesC
                                          Coises @Alan Kilborn
                                          last edited by

                                          @Alan-Kilborn said in [New plugin] Columns++:

                                          The Scintilla feature controlling both is called indicators.

                                          Thank you. I will study that and see if I can use it. Perhaps it will even help solve the problem of “non-rectangular rectangular selections” that arises in cases like your example with repeated replace where the old and new text lengths differ.

                                          By the way, I had an admittedly brief look at your source code for the plugin, and it looks excellent; nice job.

                                          Your help html file is also a joy to look at; other programs could use such a concise and well-written help file as a model. I’m curious what tool you might have used to assist in producing this?

                                          Thank you, Alan. The HTML/CSS/Javascript is hand-written in Notepad++, proofing in Firefox. I used what I wrote when I re-designed my personal web site about six years ago as a model, so there are probably some left-overs in the CSS that don’t look “purpose-built” only because I didn’t factor out all of the complexity I had needed for more diverse pages.

                                          1 Reply Last reply Reply Quote 0
                                          • CoisesC
                                            Coises @Mark Olson
                                            last edited by

                                            @Mark-Olson said in [New plugin] Columns++:

                                            One change I would consider making to the Add Numbers and Average Numbers commands is to make it very clear that the command copies the result to the clipboard. Some users will probably be unhappy that you overwrote their clipboard data without telling them that that’s what you were going to do.

                                            Good point. I’ve been using a clipboard manager for so long, I’d forgotten how upsetting it can be to lose the contents of the clipboard at the wrong time.

                                            OTOH, stating that clearly would result in some more cumbersome verbiage that lacks the nice simplicity of the current command names.

                                            @Alan-Kilborn said in [New plugin] Columns++:

                                            Currently it pops up a box with the result; perhaps having this box have 2 buttons, “OK” and “Copy”, would be an acceptable way around doing an automatic (and perhaps unwanted) copy.

                                            This makes sense. I fussed about with that little pop-up a lot. The one thing I knew I didn’t want was what I’d seen in some other plug-in: the result displayed in a dialog box with no way to put it into the document, or anywhere else, other than to recite the numbers in my head and try to type them before I forget them. I tried just copying, along with inserting the results if space was left at the end of the selection, but it seemed like there had to be some visual indication that something had happened, especially if there was no place to insert results, or if that place was not visible. So I came up with this little pop-up that tells you what happened and then disappears on its own when you click anywhere, without consuming the click unless you click on the pop-up. (I meant for it to do the same with typing, but haven’t yet gotten that to work as intended.)

                                            I will replace that peculiar little pop-up with a more standard dialog box offering options to copy or not copy the results.

                                            Alan KilbornA 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            The Community of users of the Notepad++ text editor.
                                            Powered by NodeBB | Contributors