You are probably best off hitting dat Tab key 5 times in your example.
More elegantly, you can have vim repeat the typing for you. But with its ≥7 keystrokes, 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
At the cost of more verbose syntax, the technical answer to your question is 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