You are probably best off just hitting dat Tab key 5 times in your example:
:%s/\s\(item.\)/\r
TabTabTabTabTab\1/g
(The tabs display as^I
in the Command-line.)More elegantly, you can have vim repeat that typing for you. But with its ≥7 keystrokes and a bit of thinking effort, this technique is only economical for a bigger number of repetitions or characters to be repeated:
:%s/\s\(item.\)/\r
Ctrl-f5
a\t
Ctrl-c\1/g
The most literal and technical answer to your question is – at the cost of even much more verbose syntax – using the
\=
syntax element for substituting by an expression [:help sub-replace-expression
], in which you could then employ therepeat()
function:
:%s/\s\(item.\)/\= "\n" . repeat("\t", 5) . submatch(1)/g
(Readability spaces not required.)
Unfortunately, vim does not provide syntactic sugar for repetition (\{5}
or otherwise) in the replacement part of the :substitute
command; almost none of the special regex syntax for pattern matching [:h pattern-overview
] is available for the replacement: :h sub-replace-special
(PS: TabTabTabTabTabTabTabTabTabTabTabTabTabTabTab)