# 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.

```
:let @q='<Ctrl-r>q' # ...and then modify
```

## 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).

```
/some-long-and-complicated-search-string # search something arcane
:%s/<Ctrl-r>//replacement-string # reuse without retyping
```

## Yank to system clipboard

```
"+y
```

## Set system clipboard contents to current filepath

```
:let @+ = expand("%")
```

## Run function on search results

Useful for transformations. The following will dashcase all capture group matches using [abolish.vim](https://github.com/tpope/vim-abolish).

```
g/\attribute :(\w\+\)/\=g:Abolish.dashcase(submatch(0))
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://timhwang21.gitbook.io/index/cli/vim/registers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
