Neovim 101 - Macros and Registers

Manage Neovim macros and registers using Lua.

5 min readDec 21, 2022


Neovim 101 — Macros and Registers

In this article, we will learn the basics of macros and registers, Lua APIs to manipulate registers, and plugins to help us manage macros and registers.

This article is part of the Neovim 101 series.

The Neovim configuration files are available in this repository.

Getting Started

Let’s get started with the basics.


There are 10 types of registers (:h registers).

  • The unnamed register
  • 10 numbered registers 0 to 9
  • The small delete register -
  • 26 named registers a to z or A to Z
  • 3 read-only registers : , , . and %
  • Alternate buffer register #
  • The expression register =
  • The selection registers * and +
  • The black hole register _
  • Last search pattern register /

We can use the :registers command to display the type and contents of all numbered and named registers.


The type can be c for character-wise text, l for line-wise text, and b for block-wise visual text.

For beginners, do go through the built-in documentation to understand them.


In the context of this article, a macro is a sequence of commands recorded to a register.

In summary,

  • We record a macro (:h recording) into a register by using the command q{0–9a-zA-Z”} (uppercase to append).
  • To stop recording, we press q again.
  • To execute the contents of the register {0–9a-z”.=*+} [count] times, we use the command @{0–9a-z”.=*+.
  • To repeat the last macro, we use @@.
  • To repeat the last recorded register [count] times, we use Q
  • To execute the contents…




Software engineer, Data Science and ML practitioner.