My editor of choice is Notepad++. It has macro capabilities, but as much as I think, I don't see how can I use it for anything.
Do you use macros in your editor that have made your work easier? (for general use I mean)
|
My editor of choice is Notepad++. It has macro capabilities, but as much as I think, I don't see how can I use it for anything. Do you use macros in your editor that have made your work easier? (for general use I mean) |
|||
|
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or specific expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, see the FAQ for guidance.
|
I don't know about Notepad++, but I use macros in Emacs to do pretty much any sort of easily repeated task. These tasks can actually be fairly complicated. A recent example is this: I had a CSV file from a database and wanted to convert it to JSON using a uniform pattern. It looked something like this (I don't remember exactly what it was):
I needed to convert it to something like:
Using an sort of script to do this would have take too long, so all I did was convert the first row manually while recording my keystrokes and then replay them on the rest of the file. It worked really well--while the execution time was slow, it only took less than a minute of my time, which is very important for a one-off task! Pretty much any sort of repeated manipulation like this is a great use case for a keyboard macro. I have definitely saved myself a lot of time thanks to Emacs macros! |
|||
|
|
Since you asked about the usage related to programming, and two other answers are related to data manipulation, one example which comes in mind is to change the coding style. For example, you often see compact
While being, IMO, more readable, they don't comply to the default StyleCop ruleset. To make them compliant, you have to put one statement per line and, for example, add
|
|||
|
|
I use them for pre-formatting SQL. For example, I have one macro that will surround a line with single quotes and then put a comma at the end. When I paste 50-100 IDs I can apply the macro to the end of the file, then copy-paste the result into a query. This one is also useful for non-SQL purposes. I have a few similar macros that turn a single line into an INSERT statement for specific tables. It makes creating INSERT scripts much easier. Most of my macros involve formatting the begining or end of the line in some way, and usually for data, not actual code. The details of your daily tasks will determine if there is anything simple and repetitive enough to be turned into a macro. I've gone for long periods on projects where there simply weren't many tasks that were worthy of editor macros. |
|||
|
|