:%s/^\(Chapter\ [0-9]\+:\ .*\)\%<30c$/\1\./g

I works fine, but needs to be repeated until no more matches are found.
I'm sure you guys more experencied with Vim scripting will be able to
complete my idea.

Well, if you're looking to make the change on every line that matches that pattern, you can take this (which I sent previously):

:s/$/\=Repeat('.', 70 - strlen(getline('.')))

and do it on every line that matches that pattern:

:g/^Chapter \d\+: /s/$/\=Repeat('.', 70 - strlen(getline('.')))

If you want to go with your "keep appending periods on lines that until they match, you should just be able to

:while 1 | %s/^.*\%<30c$/&./ | endwhile

It will raise an error when the pattern no longer matches, which will break the loop. Inelegant in its own way, but it works. :)

-tim




Reply via email to