How can I repeatedly add a character at the end of one or more lines, padding out the line(s) to a specific column?
For instance:
('x' represents column 40, not a character on the line; and there are no spaces or tabs after the text)
line one x
line two x
line three x
line eleventy-billion x
becomes
line one ------------------------------x
line two ------------------------------x
line three ----------------------------x
line eleventy-billion -----------------x
A combination of \=
, submatch(), and repeat():
:%s/\v^.*$/\= submatch(0) . " " . repeat("-", 39 - len(submatch(0)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With