Combining registers in vim

945 Views Asked by At

Is it possible to combine registers in vim? For example, if I have registers "a, "b, "c, can I easily create register "d which is a concatenation of all three? That is, without pasting them all and then selecting the whole thing.

2

There are 2 best solutions below

2
pkit On BEST ANSWER

With the command :let @a = "something" you can assign to a register.

With the command :let @A = "another thing" or :let @a .= "another thing" you can append to a register.

Lets say your registers are filled as follows (inspected using the reg command)

:reg a b c
--- Registers ---
"a Apple^J
"b Pear^J
"c Banana^J

Then you can call

:let @D = @a
:let @D = @b
:ley @D = @c

or

:let @d = @a . @b . @c

And your register d looks like

:reg d
--- Registers ---
"d Apple^JPear^JBanana
0
ephemient On
:let @d = @a . @b . @c