Community
    • Login

    Creating "copy buttons"

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    9 Posts 3 Posters 2.3k 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.
    • Jared ElickJ
      Jared Elick
      last edited by

      I have a file I use daily, with a few hundred SQL scripts that I use regularly.

      I currently use “BEGIN” and “END” tags to collapse, which helps.
      However, if I unfold the block, I then have to specifically drag and copy.

      Is it possible to put a button somewhere, that copies lines X:Y, and can be added at the beginning of each script?

      Thanks!

      1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones
        last edited by PeterJones

        You could write a PythonScript which would automate the copy process; after using Plugins > Python Script > Configuration to put that script into the Macro menu, you could use Settings > Shortcut Mapper to assign a keyboard shortcut to that script.

        It wouldn’t be a button, but it might do what you want.

        edit: while the official PythonScript homepage is at the link above, you should download the most recent from here, or using the Plugin Manager.

        Scott SumnerS 1 Reply Last reply Reply Quote 2
        • Scott SumnerS
          Scott Sumner @PeterJones
          last edited by

          @PeterJones said:

          It wouldn’t be a button, but …

          Why not? Pythonscripts are tie-able to either a keycombo OR a toolbar button … :-)

          1 Reply Last reply Reply Quote 2
          • PeterJonesP
            PeterJones
            last edited by

            I had forgotten about that. Do you have example (both for the OP, and for my curiosity) of how to connect a script to a toolbar button?

            (I vaguely remember from eons past that there was a toolbar-customizer plugin, but I never got into that one. Is the toolbar-to-py something you can “register” within the startup.py? Or someplace else?)

            Scott SumnerS 1 Reply Last reply Reply Quote 1
            • Scott SumnerS
              Scott Sumner @PeterJones
              last edited by

              @PeterJones

              how to connect a script to a toolbar button?

              It’s actually very similar to how one assigns a keycombo to a script…see Plugins (menu) -> Python Script -> Configuration…* and look to the RIGHT of the window; keyboard stuff is on the LEFT.

              For myself I only use ONE toolbar button for a PS, so I’m not sure about getting a custom graphic on this type of toolbar button…

              1 Reply Last reply Reply Quote 2
              • PeterJonesP
                PeterJones
                last edited by PeterJones

                Oh, right. I forgot about that panel.

                Experiment: I just added two of my scripts to that panel.

                • If you click on the name of the script after you’ve Added it, then you can Set Icon… to either an .ico or .bmp.
                • Each script in that panel can get a separate icon.
                • You have to restart Notepad++ to get the button to show up, whether you use a custom icon or don’t assign one
                • They do not give a tool-tip when you hover over them on the toolbar, so you’ll want to make sure you use meaningful icons that will tell you at a glance what they’re supposed to do. Good luck with that. :-)

                edit: those assignments go into %AppData%\Notepad++\plugins\config\PythonScriptStartup.cnf…

                Scott SumnerS 2 Replies Last reply Reply Quote 2
                • Jared ElickJ
                  Jared Elick
                  last edited by

                  Oh boy, time to learn some Python!

                  This probably isn’t the most complex script, so it may be a good starting point.

                  Thanks everyone!

                  1 Reply Last reply Reply Quote 2
                  • Scott SumnerS
                    Scott Sumner @PeterJones
                    last edited by Scott Sumner

                    @PeterJones

                    They do not give a tool-tip when you hover over them on the toolbar…

                    See Add tooltip with script name when hover over script toolbar button

                    1 Reply Last reply Reply Quote 1
                    • Scott SumnerS
                      Scott Sumner @PeterJones
                      last edited by

                      @PeterJones

                      this may be related to #32

                      Ugh, and I looked thru the list before opening #104…double ugh!

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