Registers

Special registers

@ followed by a register symbol represents a register. In addition to the standard numbered registers @[0-9], there are several special registers.
  • :: command register
  • /: search register
  • %: filepath register
  • ": last yanked value register
  • +: system clipboard register
  • =: expression register
:reg for a complete list.

Modify register contents with <Ctrl-r>REGISTER

Note that since macros are just command sequences stored as a string in a register, you can edit macros this way as well.
1
:let @q='<Ctrl-r>q' # ...and then modify
Copied!

Reuse contents of search register

Useful for when you search for something unwieldy to type and need to reuse it later (for a replace for example).
1
/some-long-and-complicated-search-string # search something arcane
2
:%s/<Ctrl-r>//replacement-string # reuse without retyping
Copied!

Yank to system clipboard

1
"+y
Copied!

Set system clipboard contents to current filepath

1
:let @+ = expand("%")
Copied!

Run function on search results

Useful for transformations. The following will dashcase all capture group matches using abolish.vim.
1
g/\attribute :(\w\+\)/\=g:Abolish.dashcase(submatch(0))
Copied!
Last modified 7mo ago