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

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.