John Aldridge wrote:
> The old vi way [for padding a line] would be:
> >:%s/$/<80 or more spaces go here>/g
> Actually, the caret (^) shouldn't be necessary,
> but I think it clarifies the regex.
Interesting quoting style! Anyway, that just replaces 80
chars with itself. ?? Maybe a naughty program somewhere
trimmed them. The ^ isn't necessary, but I always throw them
in too. If you really want a vi-compatible way to pad lines
to 80 chars, try this.
You need to replace ^M with a real ctrl-M and all ^[s with
real <Esc>s. Then suck the line into a register and execute
it: "xyy@x You may need to :redraw afterwards. The `S' is to
overcome :se ai if you try it in in Vim.
expand removes tabs (assuming ts=8) otherwise the padding
can look like it's wrong, even though it will be to 80 real
characters, not screen columns. If you have control
characters in lines it will still look messy however. I've
used dots not spaces in the example so you can see the
result. Lines longer than 80 are untouched. I could really
have done it for lines longer than 79 chars, but never mind.
There's quite a lot you can do with standard vi. Using vim's
features, however, makes this sort of thing much more robust.
That's obvious; I don't know why I said that.
Anyway the OPs method is a good one.
Antony (go vi, go!)