Macros in Notepad ++ Every developer needs to know about
Hi, Today I am going to write about an interesting feature in Notepad ++ every developer needs to know: Macros.
Most of the developers know that Notepad++ is a very light-weight and handy tool which does amazing stuff.
For those who do not know,
Notepad++ is a free (as in "free speech" and also as in "free beer") source code editor and Notepad replacement that supports several languages. Running in the MS Windows environment, its use is governed by GPL License.
Based on the powerful editing component Scintilla, Notepad++ is written in C++ and uses pure Win32 API and STL which ensures a higher execution speed and smaller program size. By optimizing as many routines as possible without losing user friendliness, Notepad++ is trying to reduce the world carbon dioxide emissions. When using less CPU power, the PC can throttle down and reduce power consumption, resulting in a greener environment.
You can visit the following website for further information and download:https://notepad-plus-plus.org/
Now, I am writing about this feature because, Few days ago, I was facing an issue of changing the URLs of about 1000 PDFs in a particular master website.
Ofcourse this could not be done manually. So we had a brilliant idea of doing it through Selenium driver present in Java, some brilliant Java Code which I may post some day but not now, Microsoft Excel and Notepad++.
With these, we completed the whole project in two days which was actually expected to be complete in 2 weeks.
Now, Why Macros? OfCourse to do repetitive work
That too in Notepad++? Is it really helpful? Well, decide for yourself. I am describing a particular scenario:
I will not be posting the original details here. We shall use a dummy example.
Open a new blank file in Notepad++
- Hit Start Recording
- Do what you need
- Hit Stop Recording
- Run once or multiple times or until file ends
This is the basic usage of a macro.
Now let us start.
I go to Wikipedia and Search for list of Cities present in California,
I get the entire list.
I just copy- paste the list onto our Notepad++
It looks somewhat like:
Now, we have got a lot of extra data and we need to filter out only the city names and truncate all the extra data.
We can do this in a few seconds.
I place my cursor at the end of the word "Adelanto"
I start recording the Macro from this point.
Then I select all the extra data till the new line.
I delete this data. All this is being recorded in the Macro.
In the next line we will be having "Agoura Hills" and this should not be deleted.
So I press home button, then down arrow, then end button on the keyboard
I stop recording the macro.
Now Run the above macro a 100 times and see . We get only the city names.
Refer to the below video I have compiled:
This was a small example. In right hands and intelligent brains, this can be a really powerful tool.
So use it wisely my fellow developers.
Comments
Post a Comment