Creating "copy buttons"
-
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!
-
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.
-
@PeterJones said:
It wouldn’t be a button, but …
Why not? Pythonscripts are tie-able to either a keycombo OR a toolbar button … :-)
-
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?) -
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…
-
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
.icoor.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… - If you click on the name of the script after you’ve Added it, then you can Set Icon… to either an
-
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!
-
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
-
this may be related to #32
Ugh, and I looked thru the list before opening #104…double ugh!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login