summaryrefslogtreecommitdiff
path: root/doc/pages/registers.asciidoc
blob: 973ed9c1d89f5d32101400bc6c11e578cb109271 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
= Registers

== Description

Registers are named lists of text -instead of simply text- in order to interact
well with multiselection. They are used for various purposes, like storing
yanked text, the locations of selections in a buffer, or groups captured by a
regular expression.

== Interacting

*<c-r><c>*::
    when in insert mode or in a prompt, insert the value stored in the
    *c* register (single character)

*"<c>*::
    in normal mode, select the *<c>* register (single character)

== Alternate names

Non alphanumeric registers have an alternative name that can be used
in contexts where only alphanumeric identifiers are possible.

== Default registers

All normal-mode commands using a register default to a specific one if not specified:

*"* (dquote)::
    default delete / copy / paste / replace register, used by:
    *c*, *d*, *y*, *p*, *<a-p>*, *<P>*, *<a-P>*, *R* and *<a-R>*
    (see <<keys#changes, `:doc keys changes`>>)

*/* (slash)::
    default search / regex register, used by:
    */*, *<a-/>*, *?*, *<a-?>*, *n*, *<a-n>*, *N*, *<a-N>*, ***, *<a-***>*,
    *s*, *S*, *<a-k>* and *<a-K>*
    (see <<keys#searching, `:doc keys searching`>>).
    This is a prompt history register, holding the last 100 commands entered
    at an interactive regex prompt.

*@* (arobase)::
    default macro register, used by:
    *q* and *Q*
    (see <<keys#macros, `:doc keys macros`>>)

*^* (caret)::
    default mark register, used by:
    *z*, *<a-z>*, *Z* and *<a-Z>*
    (see <<keys#marks, `:doc keys marks`>>
    and <<registers#marks, `:doc registers marks`>>)

*|* (pipe)::
    default shell command register, used by commands that spawn a subshell:
    *|*, *<a-|>*, *!* and *<a-!>*
    (see <<keys#changes-through-external-programs, `:doc keys changes-through-external-programs`>>).
    This is a prompt history register, holding the last 100 commands entered
    at interactive shell command prompts, except for commands starting with
    a space.

== Special registers

Some registers are not general purposes, they cannot be written to, but they
contain some special data

*%* (percent)::
    current buffer name

*.* (dot)::
    current selection contents

*#* (hash)::
    selection indices (first selection has 1, second has 2, ...)

*_* (underscore)::
    null register, always empty

*:* (colon)::
    prompt history register holding the last 100 commands entered at the
    interactive prompt, except for commands starting with a space.

== Integer registers

Registers *1* to *9* hold the grouped sub-matches of the regular
expression used to make the last selection. Example: applying the
following regular expression to the date of the day would put the day of
the week in register *1*, the month in register *2*, and the day of the
month in register *3*, but select the entire date:

--------------------
(\w+) (\w+) (\d+) .+
--------------------

== Marks

When a register is used to store a set of selections with the *Z* key (see
<<keys#marks, `:doc keys marks`>>), the selections are stored as a list of
spans, in a format similar to `%val{selections_desc}` (see
<<expansions#value-expansions, `:doc expansions value-expansions`>>). However,
the very first item of the list is of the form:

------------------------------------------
<buffer name>@<timestamp>@<main sel index>
------------------------------------------

with:

*buffer name*::
    `%val{buffile}` of the buffer selections relate to

*timestamp*::
    `%val{timestamp}` at which the selection applies to

*main sel index*::
    0-based index of the main selection