save repeat operations in a script?
-
Hi everyone.
I often find myself having to carry out operations of adding text at the beginning of the line, or at the end or other similar operations. Is there a way to launch a command or store these operations for quick recall? Thank you :) -
-
Thanks but I need a script that asks me, for example, what text I want to insert. The text always changes, the macro, if I understand correctly, repeats the recorded operation :(
-
@Furio-Sassi said in save repeat operations in a script?:
but I need a script that asks me
…so then write a script.
-
I hope the level of your response is not proportional to your intelligence…
-
@Furio-Sassi said in save repeat operations in a script?:
I hope the level of your response is not proportional to your intelligence…
As my intelligence is what produced my response, then I’d say the level is the same.
Did I not answer the question?
Actually you answered it yourself, when you said “I need a script”.
Surely you’ve consulted the FAQ area of this site and saw that scripting is possible and some hints on how to do it. -
@Furio-Sassi said in save repeat operations in a script?:
I hope the level of your response is not proportional to your intelligence…
He was being terse, but accurate. You, on the other hand, just replied with an insult, adding nothing to the conversation.
The owner of Notepad++ decided to leave the Macro system simple (without prompts or logic), expecting users who need more than that to be able to use one of the scripting plugins to make a more advanced script on their own. Hence, if you need something more advanced than a macro can provide, the correct answer is that you need to write a script.
----
Please note: This Community Forum is not a data transformation or free-code-writing service; you should not expect to be able to always say “I have data like X and want it to look like Y” and have us do all the work for you. If you are new to the Forum, and the problem can be easily solved with a regular expression, we’ll likely give you a start on that. And if it requires scripting (more complex logic than can easily be done in a regular expression), we will let you know. If your problem catches the interest of one of the regulars, that person may even provide an example script that may be helpful; often times, we might even ask you to search the forum for a particular term, because that term will likely help you find a script that already implements something similar. Whether it’s a previously-written script, or whether one of us hacks something up for you specifically, it won’t always exactly match your problem, but it’s at least a starting point for you to work from. At that point, you are expected to take the lead, and make any changes to the example that are necessary to convert it from what was provided to something that meets you exact needs. This forum is focused on Notepad++; while you may want to use Notepad++ for the implementation, text editors aren’t always the right tool for complex text transformation tasks: since you are seeing this boilerplate in my reply, it means that I believe that it’s essentially a generic programming challenge, which is off topic for a Notepad++-specific forum.
-
I hope you are joking.
If a person asks for help with a script, they OBVIOUSLY don’t know how to do it. Nobody forced the genius to answer me and not even you to intervene in his defense and make a terrible impressionSo I repeat my request for help from kind and helpful people
I forgot, if you think his answer is intelligent, where would my offense be? In your opinion, his response was intelligent and my hope is that his intelligence is proportional, therefore very intelligent ^_^
-
@Alan-Kilborn said in save repeat operations in a script?:
@Furio-Sassi said in save repeat operations in a script?:
I hope the level of your response is not proportional to your intelligence…
As my intelligence is what produced my response, then I’d say the level is the same.
Did I not answer the question?
Actually you answered it yourself, when you said “I need a script”.
Surely you’ve consulted the FAQ area of this site and saw that scripting is possible and some hints on how to do it.because obviously, when you want an answer and you need it with a certain urgency, you don’t ask for help, you read all the FAQs, manuals (moreover in a language you don’t understand well)…right???
But aren’t you ashamed to intervene in a request for help with a response like that? For the things in which I am competent, I help whoever I can without being a professor. Evidently these are your satisfactions :)
-
@Furio-Sassi said in save repeat operations in a script?:
I hope you are joking.
Nope. We’re here to help people use Notepad++, not do everything for them.
If a person asks for help with a script, they OBVIOUSLY don’t know how to do it.
And your problem description is too generic for anyone to write a script for you, even if we were so inclined.
Noone is going to write a whole new macro language for you with that addition of a prompt box – and that’s what would be required to solve the nebulous, generic inquiry you wanted.
If you had a specific task, someone could give you an answer, but what you’ve asked for is too generic. So the generic answer is “it cannot be done unless someone who knows what problem you are trying to solve takes an interest” – and until you provide details, no one will know what problem you are trying to solve; and until you change your attitude, I am doubtful anyone will take an interest.
Despite my uncertainty about what you really want, I’ll give it a go below, but I’m quite sure you won’t like the answer.
Nobody forced the genius to answer me
Sarcastic compliments are still insults.
and not even you to intervene in his defense and make a terrible impression
I am sorry I made a terrible impression by telling you that we weren’t a code-writing service.
So I repeat my request for help from kind and helpful people
I am typical helpful in this forum, and I try to be kind. But as a major contributor to this forum, I don’t like it when people who come in, demand help on their terms, and then start throwing around insults when they don’t like the answer they are getting.
because obviously, when you want an answer and you need it with a certain urgency,
Your urgency doesn’t change the fact that this forum is a Community of fellow users of Notepad++, not a paid immediate-support group. If you want people to help you for free, you have to understand the limitations of such.
Again, if you weren’t so demanding and insulting, people would be more willing to help. But since you seem to think I’m not helpful, I will belie that.
Here is a script for the PythonScript plugin that will ask for some text, and then place that text at the beginning of every line of your file that already has text (skipping blank lines). (Your problem description, again, was way too vague to get a meaningful custom script.)
from Npp import * txt = notepad.prompt("Text", "Enter text to be put at the start of every line") editor.rereplace(r'^(?=.)', txt)
If you don’t like that exact action, you can then customize the regex (which goes between the
r'
and the'
) using the same regex syntax of the find/replace dialog, which will then choose exactly where to put the prompted text.This reply then shows that despite you being insulting and me apparently making a bad impression on you for calling you to task for being insulting, I can still try to be helpful – whether you’re willing to accept that help or not, I cannot control. Good luck in the future.
-
Let’s not be hypocrites, all of us, when we need help, often ask for help in forums without reading the manuals, especially if they are in foreign languages. If this were not the case, the forums would be deserted.
And no one forces those who respond to write, if they do so it is done out of altruism or vanity. What is not acceptable is being taken for a ride with “write the script” responses, as if someone goes to the doctor for a pain and the doctor tells him to start studying medicine!Thank you for the explanation, I will try to understand these days, thanks :)
-
@Furio-Sassi said in save repeat operations in a script?:
Let’s not be hypocrites, all of us, when we need help, often ask for help in forums without reading the manuals, especially if they are in foreign languages.
Right, and in every forum I’ve seen for the decades I’ve been on the internet, when someone asks a question where a FAQ would have been helpful, they are pointed to that FAQ, whether kindly or rudely.
What is not acceptable is being taken for a ride with “write the script” responses, as if someone goes to the doctor for a pain and the doctor tells him to start studying medicine!
Yes, but you are paying the doctor to help you.
Your action has been more like going into a room full of random strangers and demanding that they do your job for you, for free, immediately.
Thank you for the explanation, I will try to understand these days, thanks :)
-
@PeterJones
The question is not generic, having to automate the insertion of text at the beginning or end of the line is extremely clear and, apparently, not complicated. But I’m not a programmer and I didn’t know it was difficult. In this case, kind people write to you that it is complicated, time-consuming and that they don’t have the time or desire to do it. This is the correct answer that must be given in these casesAnd passing off my request for help as a demand and even rude is an interpretation you make in bad faith and what I wrote in the request is there for you to read.
I don’t like your answer, I don’t like the hypocrisy of pretending you’ve never asked for help on a program without reading the FAQs in languages you don’t know and I don’t like that you intervened to defend the indefensible.
In short… we don’t like each other :)I forgot… and in Italy we have doctors for free :) and the paid ones have it written on the door and I don’t think I’ve read a price list on the forum
-
@Furio-Sassi said in save repeat operations in a script?:
I often find myself having to carry out operations of adding text at the beginning of the line, or at the end or other similar operations. Is there a way to launch a command or store these operations for quick recall? Thank you :)
Notepad++ does not have any built in scripting other than the macro system which is very limited.
The Scripts: Creating & Editing forum thread was active five years ago. Nearly everything written then is true today other that 64-bit support is now available.
The scripting languages available as Notepad++ plugins allow you to steer or drive Notepad++ through a series of operations. They support conditional logic where you can say
if something then do this
. They support loops both in the form ofdo something ten times
ordo something until this happens
. They support variables which are handy for storing temporary or intermediate results.Google up examples of how to do things in NppExec, PythonScript and LuaScript to see which language seems less mystifying and then dive in.
-
@Furio-Sassi said in save repeat operations in a script?:
@PeterJones
The question is not generic, having to automate the insertion of text at the beginning or end of the line is extremely clear and, apparently, not complicated.Your original description said you wanted to “store these operations for quick recall”. That is highly generic, and a script to do that would be complicated. For the specific case of “at the beginning of the line”, it’s much easier (and hence my answer).
And passing off my request for help as a demand and even rude is an interpretation you make in bad faith and what I wrote in the request is there for you to read.
The original request wasn’t a demand. And I gave you the right answer for that request, because your original request didn’t say you needed to prompt for information at the start. I was perfectly happy in that interaction.
I started reacting negatively to you only when you started questioning the intelligence of other members of the forum (because personal attacks are forbidden in this forum). (As a moderator of this forum, and with the stated policy of the forum being no personal attacks, I would have been justified in taking moderator action against you; but questioning someone’s intelligence is rather a minor infraction, so I chose to just point out the rudeness in hopes that you would stop your insults.)
And then I escalated again when you made the comment about the supposed “urgency”, because expressing a sense of urgency on our replying to you makes it obvious that you didn’t understand the volunteer nature of this forum.
I don’t like your answer,
Do you mean my answer about the macros? It was right given the original description, so there’s not a good reason for disliking it.
Or do you mean you don’t like the script I gave you for free? It did what you asked for in your follow on – it prompted for some input text, then put it at the beginning of certain lines. And taking the same concepts, and a little effort or research into regex, and you could expand that to end of lines, or beginning/end of specific lines, or what have you.
I don’t like the hypocrisy
You assumed hypocisy, because you assumed behavior I never claimed. That’s really not my fault.
of pretending you’ve never asked for help on a program without reading the FAQs in languages you don’t know and I don’t like that you intervened to defend the indefensible.
I never pretended that, or made such a claim.
But since you “asked”, my expectation is that when i post a question in a forum without first reading the FAQs, if it turns out my question is answered in a FAQ, I will expect them to point out this FAQ to me, and until I have shown evidence of reading the FAQ, I don’t expect any more input from them, no matter how much more I ask or whine. Being told to “read the manual” or “read the FAQ” – especially if the specific section is pointed out, but even when it’s not – is a completely valid response to any question that is answered by the manual or the FAQ
I forgot… and in Italy we have doctors for free :) and the paid ones have it written on the door and I don’t think I’ve read a price list on the forum
There isn’t a financial price on the forum – though there is the “price” that your behavior and attitude should be commensurate with a free community rather than expecting people to instantaneously do everything for you for free.
In short… we don’t like each other :)
I don’t like that you were rude. I don’t like that you’re argumentative. I don’t like that you brought up “urgency” to try to “encourage” people to help you.
But I have no opinion of how would be in real life to deal with: most people – including myself – are less filtered in their behavior on the internet, which can be both a boon and a bane, depending on circumstancse. As a result, I try to not form opinions on a person as such, and instead just focus on behavior. I neither like nor dislike you as a person – I just don’t like your behavior. (And to me, there is a difference between not liking a person’s behavior and not liking a person).
But again, because you don’t like me, this will be the last you hear from me, unless you violate the policies of the forum forbidding hate speech, personal attacks, and other egregious misbehavior.
Bye.
-
@mkupper said in save repeat operations in a script?:
@Furio-Sassi said in save repeat operations in a script?:
I often find myself having to carry out operations of adding text at the beginning of the line, or at the end or other similar operations. Is there a way to launch a command or store these operations for quick recall? Thank you :)
Notepad++ does not have any built in scripting other than the macro system which is very limited.
The Scripts: Creating & Editing forum thread was active five years ago. Nearly everything written then is true today other that 64-bit support is now available.
The scripting languages available as Notepad++ plugins allow you to steer or drive Notepad++ through a series of operations. They support conditional logic where you can say
if something then do this
. They support loops both in the form ofdo something ten times
ordo something until this happens
. They support variables which are handy for storing temporary or intermediate results.Google up examples of how to do things in NppExec, PythonScript and LuaScript to see which language seems less mystifying and then dive in.
Thanks for the help. Do you happen to know a text editor that supports scripts?
-
@PeterJones said in save repeat operations in a script?:
@Furio-Sassi said in save repeat operations in a script?:
@PeterJones
The question is not generic, having to automate the insertion of text at the beginning or end of the line is extremely clear and, apparently, not complicated.Your original description said you wanted to “store these operations for quick recall”. That is highly generic, and a script to do that would be complicated. For the specific case of “at the beginning of the line”, it’s much easier (and hence my answer).
And passing off my request for help as a demand and even rude is an interpretation you make in bad faith and what I wrote in the request is there for you to read.
The original request wasn’t a demand. And I gave you the right answer for that request, because your original request didn’t say you needed to prompt for information at the start. I was perfectly happy in that interaction.
I started reacting negatively to you only when you started questioning the intelligence of other members of the forum (because personal attacks are forbidden in this forum). (As a moderator of this forum, and with the stated policy of the forum being no personal attacks, I would have been justified in taking moderator action against you; but questioning someone’s intelligence is rather a minor infraction, so I chose to just point out the rudeness in hopes that you would stop your insults.)
And then I escalated again when you made the comment about the supposed “urgency”, because expressing a sense of urgency on our replying to you makes it obvious that you didn’t understand the volunteer nature of this forum.
I don’t like your answer,
Do you mean my answer about the macros? It was right given the original description, so there’s not a good reason for disliking it.
Or do you mean you don’t like the script I gave you for free? It did what you asked for in your follow on – it prompted for some input text, then put it at the beginning of certain lines. And taking the same concepts, and a little effort or research into regex, and you could expand that to end of lines, or beginning/end of specific lines, or what have you.
I don’t like the hypocrisy
You assumed hypocisy, because you assumed behavior I never claimed. That’s really not my fault.
of pretending you’ve never asked for help on a program without reading the FAQs in languages you don’t know and I don’t like that you intervened to defend the indefensible.
I never pretended that, or made such a claim.
But since you “asked”, my expectation is that when i post a question in a forum without first reading the FAQs, if it turns out my question is answered in a FAQ, I will expect them to point out this FAQ to me, and until I have shown evidence of reading the FAQ, I don’t expect any more input from them, no matter how much more I ask or whine. Being told to “read the manual” or “read the FAQ” – especially if the specific section is pointed out, but even when it’s not – is a completely valid response to any question that is answered by the manual or the FAQ
I forgot… and in Italy we have doctors for free :) and the paid ones have it written on the door and I don’t think I’ve read a price list on the forum
There isn’t a financial price on the forum – though there is the “price” that your behavior and attitude should be commensurate with a free community rather than expecting people to instantaneously do everything for you for free.
In short… we don’t like each other :)
I don’t like that you were rude. I don’t like that you’re argumentative. I don’t like that you brought up “urgency” to try to “encourage” people to help you.
But I have no opinion of how would be in real life to deal with: most people – including myself – are less filtered in their behavior on the internet, which can be both a boon and a bane, depending on circumstancse. As a result, I try to not form opinions on a person as such, and instead just focus on behavior. I neither like nor dislike you as a person – I just don’t like your behavior. (And to me, there is a difference between not liking a person’s behavior and not liking a person).
But again, because you don’t like me, this will be the last you hear from me, unless you violate the policies of the forum forbidding hate speech, personal attacks, and other egregious misbehavior.
Bye.
Thanks for the attempt to argue, unfortunately not speaking your language correctly does not prevent me, and anyone else reading this thread, from understanding who is wrong and who is right. Who was educated and who was not and who defended who was not. Those who climb on mirrors and those who have the serenity to clarify the incorrect and arrogant behavior that some people have on the forums. For my part, in the topics I know, if I frequent a forum I do it to be available and not to be morally easy, especially when the requests for help come from foreign people who are not even programmers. An EMPATHIC person understands these things and makes himself available. Those who frequent the forums for other less noble issues are too busy with themselves, waiting for the bonus and making their skills count to feel “better”… that’s not my case.
Everything would have been simpler with a banal “Notepad+ does not support scripts” and perhaps recommending a program that supports them. But, as I wrote, you are NOT motivated by the desire to help but you are looking for gratifications, I’m sorry for you, evidently you don’t have many in life… I wish you the best, thanks again -
@Furio-Sassi said in save repeat operations in a script?:
Do you happen to know a text editor that supports scripts?
Notepad++ has syntax highlighting for scripts but won’t offer help or hints as you are typing.
There are editors known as IDE “integrated development environment” which allow you to single step through the script with the IDE also showing you what variables are being changed. It’s an area I’m not familiar with and particularly, an IDE that would let you trace or debug a Python script activated from Notepad++ and is doing Notepad++ and/or Scintilla specific things.
-
@mkupper said in save repeat operations in a script?:
@Furio-Sassi said in save repeat operations in a script?:
Do you happen to know a text editor that supports scripts?
Notepad++ has syntax highlighting for scripts but won’t offer help or hints as you are typing.
There are editors known as IDE “integrated development environment” which allow you to single step through the script with the IDE also showing you what variables are being changed. It’s an area I’m not familiar with and particularly, an IDE that would let you trace or debug a Python script activated from Notepad++ and is doing Notepad++ and/or Scintilla specific things.
Everything clear, thanks for the help! :)
And I would also like to make peace with those I argued with, in the world there are so many reasons to argue that it would be stupid to argue even over something stupid like that. I came here in complete good faith, before writing I had also looked for information on macros (as I specified in my second post where I wrote “the macro, if I understand correctly, repeats the recorded operation”) but I had not found any references to scripts , that’s why I asked for help. Then the discussion took a direction I didn’t want.
Thanks everyone, bye :)