iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🎃

How to Save and Reuse Vim Macros

に公開

Here is a method for saving a macro once created so that you can reuse it even after reopening Vim.
I will explain using an example of saving to the macro @b.

Saving to .vimrc

Recording a macro with q

qb → actions → q to record.

Adding to .vimrc

let @b = 'Gk$F_lvEygg$p

(When you want to copy to an external clipboard, etc.)

"bpyy

"b Select b → p paste → yy copy to keep it in the external clipboard.

:echo @b
:reg b

You can also verify it with these commands.

GitHubで編集を提案

Discussion