A.J.Mechelynck wrote:
It should be possible (though less obvious) to do it with only a
substitute. Let's try:
:'<,'>s/^.*\S.*$/# \0
i.e. prepend a hash sign and a space wherever we find start-of-line,
zero or more of anything, one nonblank, zero or more of anything,
end-of-line (in the range, here shown as a Visual area).
OK, here's another possible but less obvious method, even a bit shorter:
:'<,'>s/^.*\S\&^/%/
This one uses a "concat", and depends on having the last "concat" be the
one used for substitution.
What it means:
:'<,'> over the visually selected range
s substitute the pattern that begins with something but has a
non-whitespace character,
AND matches the beginning-of-line
with a % in the place of the last concat (ie. the beginning-of-line).
Regards,
Chip Campbell