• Login
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.
  • J
    Jared Elick
    last edited by Sep 13, 2018, 12:16 AM

    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
    • P
      PeterJones
      last edited by PeterJones Sep 13, 2018, 1:21 PM Sep 13, 2018, 1:19 PM

      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.

      S 1 Reply Last reply Sep 13, 2018, 2:59 PM Reply Quote 2
      • S
        Scott Sumner @PeterJones
        last edited by Sep 13, 2018, 2:59 PM

        @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
        • P
          PeterJones
          last edited by Sep 13, 2018, 3:51 PM

          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?)

          S 1 Reply Last reply Sep 13, 2018, 3:56 PM Reply Quote 1
          • S
            Scott Sumner @PeterJones
            last edited by Sep 13, 2018, 3:56 PM

            @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
            • P
              PeterJones
              last edited by PeterJones Sep 13, 2018, 4:21 PM Sep 13, 2018, 4:20 PM

              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…

              S 2 Replies Last reply Sep 13, 2018, 5:35 PM Reply Quote 2
              • J
                Jared Elick
                last edited by Sep 13, 2018, 4:28 PM

                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
                • S
                  Scott Sumner @PeterJones
                  last edited by Scott Sumner Sep 13, 2018, 5:35 PM Sep 13, 2018, 5:35 PM

                  @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
                  • S
                    Scott Sumner @PeterJones
                    last edited by Sep 13, 2018, 5:43 PM

                    @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
                    3 out of 9
                    • First post
                      3/9
                      Last post
                    The Community of users of the Notepad++ text editor.
                    Powered by NodeBB | Contributors