start-kbd-macro default binding: ‘ C-x (’ - Starts recording a keyboard macro.Simply writing the macro so it moves the cursor to the next line may be adequate. Of course, when merely changing successive lines it may not be necessary to search at all. If you find the cursor positioned at a point you do not wish to change, C-s C-s repeats the last search of the macro and will move you to the next likely modification point. This method leaves the TextCursor positioned at the beginning of a search target, which means that you can see what will be changed should you again invoke the macro.
It can do a lot of file-munging that you would do otherwise with a throw-away Perl script or Awk script. markers.Įmacs macro are a powerful one-shot text-processing tool. I changed all the bold asterisks into into. I used keyboard macros to manipulate this page. c file, and recorded a keystroke macro that converts “MY_CONSTANT” into “case MYCONSTANT: break”. I copied the list of enumerated constants from the header file to my. I once needed to write a C switch() statement for an enumerated type. Instead of spending time to discover how the debugging output was generated, I used Emacs macro to search and remove the noise from the output. I was once debugging somebody else’s code, and their debugging output was generating lots of noise that did not pertain to the bug.
I once used Emacs macro to translate Ruby code to Scheme code, by adding parenthesis at the right places. When I need to make the same kind of change to a number of similar entities, I use a keyboard macro.įor instance, I once used an Emacs keyboard macro to reduce the content of a HTML table down to gnuplot’s input format (to plot the data).