How to Quickly Store Vim Macros on Mac OS
The aim of this pageđź“ť is to describe making mass changes in vim known as macrod/command recording adding the counter-intuitive insight that on new Mac OSs/new Vim the macros are recorded automatically. I am using this currently just for a simple checkbox adder (newline + - [ ]
) and checker (changing empty checkbox into - [x]
once I am done)
2 min readFeb 13, 2024
- press
q<register_name>
, e.g.qa
- type commands here
- press
q
- position yourself to the location of beginning of mass-change
- run the macro by
@<reqister_name>
, e.g.@a
- to repeat the call of the previously executed macro, press
@@
- On macOS with vim 8.x and newer — the actions are automatically stored in the
.viminfo
file. - The suggestions of https://stackoverflow.com/questions/2024443/saving-vim-macros are no longer relevant — at least for basic tssks
- The
.viminfo
file is a persistent storage file that Vim uses to store various information, including recorded macros. - The recorded macro will be stored in the specified register and will be available for future use, even after restarting Vim or logging out of mac OS.
- To record a macro, press “q” followed by a register key, perform the actions, and press “q” again to stop recording.