We pretty much type everyday, every working hour. Let it be Excel, Word, Powerpoint, Visual Studio, HTML, or simply your Email. We code, we write articles, we write mails, we write scripts and so much we do with text. And then you stumble across certain tasks that is repetitive, and you wish if you could automate it so it gets done in a click, don’t you ?
So, sometimes you just wish you could type things faster, or at many places together, or copy one code element at 10 different places in one go, or things of similar sort. You might want to replace with one letter at multiple places, or just add some text before and after your 200 line code. You might thing this is do-able in excel, but do-able is just not enough anymore. You need to move to multi-editing !
Rejoice, your favorite editors Notepad++ and Sublime has this feature already. Let’s see how to do that in Notepad++.
Go to Settings – Preferences – Editing – Enable ‘Multi-Editing Settings checkbox’
Lets say you have your text like –
And you need it like –
The cost of abc is 123
The cost of def is 456
The cost of ghi is 789
Of course this is breeze in excel but we don’t prefer that since –
-Excel can bring in garbage values that can cause error in codes
-Creating that formula is tricky when you have characters like +=- etc
So how we do it in Notepad++ ? Lets see –
Once you have enabled multi-editing using above steps, simply place your cursor before abc in the first line, then hold Ctrl and click before ‘def’, and while you are holding Ctrl, click before ‘ghi’ also. You will see a cursor is blinking in front of each row.
Now, start typing. You will see that you are automatically typing at 3 places in one time.
Done. You have just achieved it in 5 seconds that would take a minute in Excel !
Also, Explore the Record Macro functionality that lets you do multiple things on a row and then repeat it over other lines in one click.
Here is how ->
- Place your cursor at the start of your text, click the ‘record’ button in the ribbon, and then edit just that one row of text. You may only use arrow keys or ctrl+arrow keys to move around characters/words rather than clicking with your mouse. The ‘home’ and ‘end’ keys are also useful.
- When you’re finished with that one line, move your cursor (again without using the mouse) to the start of the next line.
- Click the ‘stop recording’ button.
- Click the ‘play macro’ button to check that it works on the next line as expected.
- Click the ‘run macro multiple times’ to do it for all the lines of the code, and you would see the magic happening in seconds !
Watch this video tutorial to see how to do it. If you like the post and found it quite useful in your daily work, don’t forget to send me a comment.
Hope you enjoyed the video and the blog. Until next time, keep coding !