A very useful tool in Emacs is the keyboard macro. Every so often I need to perform a repetitive task that is slightly different each time. This time, I was changing casts again, in C++. I had a series of casts, that looked like this: (MeasureLine *)(annot->newCopy()); and I needed to replace them with this: dynamic_cast<MeasureLine *>(annot->newCopy()); So I defined a keyboard macro, where I first selected 'MeasureLine *', and the macro would cut that text, type in 'dynamic_cast<', paste, then type '>' The keyboard macro is started by the keystroke 'Ctrl-x (', and ended with 'Ctrl-x )'. It is run by 'Ctrl-x e' When I found another spot in my code that looked like this: (ConstraintPlane*)(annot->newCopy()); I could drag over 'ConstraintPlane*' with my mouse, and hit 'Ctrl-x e', and it turned into: dynamic_cast<'ConstraintPlane*>(annot->newCopy()); Done. Another trick is that 'Ctrl-u
Comments