Skip to content
Search

Vim:Registers

lastmod 2023-04-06created 2023-04-061 edits

Notes on VIM registers.

Available registers

a - z / A - Z

The named registers

0 - 9

The numberered registers

"

The unnamed register

-

The small delete register

%

Contains the file name (read only)

: / .

Other read only registers

#

The alternate buffer

=

The expression register

* / + / ~

The selection and drop registers

/

The last search pattern register

_

The black hole register

Types of registers

A register is one of the following three types.

  • characterwise (character range)
  • linewise (line range)
  • blockwise-visual (block range)

The register type can be set with the third argument of setreg().

Reading and writing registers programmatically

In scripts and ex commands, a register value can be accessed by prefixing it with the at sign (@).

let l:value_of_register_f=@f
let @f='change value of register f'

The value of a register with a dynamic name can be set with setreg().

Assigning to uppercase registers

Assigning a value to an uppercase register actually appends the assigned value to the value of the corresponding lowercase register.

Clearing register contents

A register (here, r) can be cleared as follows.

:let @r=''

However, a few keystrokes can be saved by recording nothing into the register: qrq

See also

Favorite site

author Zer0 sitemap