views:

124

answers:

2

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.

+3  A: 
:let @d = @a . @b . @c
ephemient
+8  A: 

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
pkit
I find `:let @d .= @a` easier to remember/type than `:let @D = @a`, and also just doing that for each register that presumes `"d` is empty first (which of course can be ensured, using `:let @d = ""`). Good explanation, though.
ephemient
Indeed it seems easier. I actually wasn't aware of the `.=` notation.
pkit