Recording, editing, and using macros
Macros can be very helpful; they are saved with the .sublime-macro
extensions as a JSON-formatted file.
Before creating a new macro, we should understand what the use case is. If we find ourselves doing the same actions over and over again, we should use a macro for it. For example, when writing C# code, we always go to the end of the line to insert a semicolon and press Enter. How can we do this faster?
Recording a macro
To record a macro, simply press Ctrl + Q on Windows or Linux and Control + Q on OS X. We will notice that the status bar says Starting to record macro…, as shown in the following screenshot:
Let's record the macro. Press Ctrl + right arrow + ; + Enter on Windows or Linux and Command + Right Arrow + ; + Return on OS X. Finally, press Ctrl + Q to stop recording.
Playing a macro
To play the recorded macro, simply press Ctrl + Shift + Q on Windows or Linux and Control + Shift + Q on OS X. Sublime will always play the last recorded macro.