I'm trying to repeat register couple of times and assign it to another register whilst concatenating the strings.

For example:

let @d = '<td></td>'
let @r = '<tr>' . 10@d . '</tr>'
let @t = '<table>' . 10@r . '</table>'

However this syntax is not allowed.

Is there any different syntax or workaround to achieve that without repeating n-times?

1 Answer 1


There's the repeat() function:

repeat({expr}, {count})
Repeat {expr} {count} times and return the concatenated result.

Example usage:

:let @d = '<td></td>'
:let @r = '<tr>' . repeat(@d, 3) . '</tr>'
:let @t = '<table>' . repeat(@r, 2) . '</table>'

:echo @r

:echo @t

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.