Macros are nothing but mapping of some pattern to some other pattern. It becomes very handy to use macros in our computer program to make some repetitive and frequently used logic shortened.
Example #define PI 3.14
is one of the most known examples for macros. Here the PI is replaced by 3.14 in every place of the program where PI is used before compilation.
Keyboard and Mouse Macros
- They are used to specify the task(sequence of keystrokes) that needs to be performed when a certain keystroke or input is given. By this, the repetitive sequence of keystrokes and mouse movements can be automated. Here we are mapping a short mouse event to the sequence of repetitive mouse events.
Fun Fact: Your best editor(maybe) Emacs is the short form for “Editing macros”.
Emacs (and also Vim) supports macros where you can map certain keystrokes to another.