tags:

views:

318

answers:

6

Just as the title says, I see a lot of editors touting macro recording as a feature but cannot find a way to take advantage of these functions myself. So what can you use it for? The type where you can record mouse movement and/or keystrokes? Is it really that helpful to people out there? Specifically, I deal with Eclipse which has a number of built in "fill in" functions, so I really don't see what the advantages could be.

A: 

Waaaay back I used a macro to make function header/comments. Other than that I have not used them.

Basically you can "automate" tedious things you do often that do not have built in ways to do the tasks you do frequently. It is a flexible way to give lots of power to people so they can work more efficiently.

Tim
So are macros a holdover from long defunct IDEs? I was looking at SlickEdit and noticed one of the touted features was macro recording. Seeing as you can do almost anything with a keyboard shortcut, I was wondering if there was any use at all for recorded user keystrokes.
Organiccat
Maybe - but there are probably good uses for them still. Being able to record keystrokes is pretty great so that you can customize your own tools and reduce keystrokes and tedious editor manipulation
Tim
+3  A: 

I use them all the time. Say, for example, I want to go down a list, indenting by 4 and adding a "|* ". In EMACS, I hit C-x ( to start recording, do one example line to see that it's what I want, ending with C-n C-a to move to the next line, and end the macro with C-x ). Then C-x e repeats it line by line, and C-u number C-x e does it many times.

Charlie Martin
Most of the things done with macros can be done with regexp search/replace. However, in some case (nested parenthesis, multiline data chunks, need to do lookup in another window) macros are indispensable. And sometimes they are just simpler than the corresponding regexp.
Arkadiy
Ah, that's a use for them I suppose. It seems to me that for the most part, IDEs these days for more recent languages don't really need macros anymore because of the enhanced capabilities of the IDE itself. Still, I can see a few formatting issues being handled by macros.
Organiccat
++ Sometimes you just need to do the same set of keystrokes over and over again. This is exactly what macros are for.
Harvey
regex-replace is handy too, but I like macros because you can do them "by example" -- make sure you're doing what you want. By the way, you can embad a regex-search *into* an emacs macro. -- Organicat, the thing is, not everything I do is code.
Charlie Martin
A: 

I find it very useful in microsoft excel. Rather then having to look through documentation to find every object and function I need to call I can record a macro that does most of what I want, take that code and modify it to give me finer control.

Jared
Even better with Excel - record the basic macro of what you are trying to do and the clean up the recording so that it works better. For some of the small macros that I write for some of my coworkers it turns a task that might take an hour into about 15 minutes.
Rob
A: 

Hello,

In Visual Studio, I use macros for many different purposes. One of the most valuable comes when debugging Windows service. I can use the macro engine to start and then attach to the Windows service which just a click of a button.

Also, sometimes I use custom DEFINES that need to be exploded into code--sort of like C/C++ macros.

Colby Africa

Colby Africa
A: 

Depends on what you are doing and what language you are work with. As a simple example, right now I am working with a Visual Basic .NET application that has a number of queries in it. I generally do all of my work with queries in Toad, but Visual Basic .NET has an annoying syntax when it comes to long strings, namely:

Public Const SelectData As String = _
"SELECT * " & _
"FROM myTable " & _ 
"WHERE myField = :SOMETHING"

Since I really don't like editing the queries when I copy them out of the code or pasting them back in, I have some macros that will automatically format or strip the formatting from them.

Also, some of the macros can be used to automate common tasks that you need to do around the IDE while you are working. Any sequence of commands that you see yourself doing often is something that you can turn into a macro and do with just a single click.

Rob
A: 

I don't use them in Eclipse either. Here's why:

  1. Eclipse has many powerful built-in functions and refactorings. So with code, its not necessary.

  2. Eclipse macros aren't that great. You can record them, but its hard to tweak them and do exactly what you want.

  3. Macros become more useful in things like modifying files that aren't code. For that I tend to use something like vim. Also, you have to actually practice using macros to recognize when they will help.

Dutch Masters