If a line contains a , this , should have only one space character and
also only one space character
after it. How do you do that?
So the following:
sX,sY
sX ,sY
sX, sY
sX , sY
Must all be come (the last one should be trimmed to one space before
and after the ,)
sX , sY
Rgds,
Jeri
Imho with a simple :1,$ s@ *, *@, @g
Based on the OP's example, that's missing a space before the
replacement comma:
:%s/ *, */ , /g
should do the trick. If tabs are to be considered spaces too,
you can use
:%s/\s*,\s*/ , /g
instead.
-tim
Are you sure?
It is possible, but the usual typographical (and programming) convention
is to have no space before a comma, and one space after it except at the
end of a line or before another comma, closing quote etc.
To do what you ask (untested)
:%s/\s*,\s*/ , /g
This ought to replace any comma preceded and followed by zero or more
spaces and tabs by space-comma-space. I think that consecutive commas
will get two intervening spaces instead of one though.
Best regards,
Tony.
--
Anything worth doing is worth overdoing
[deleted]
> Are you sure?
>
> It is possible, but the usual typographical (and programming) convention
> is to have no space before a comma, and one space after it except at the
> end of a line or before another comma, closing quote etc.
[deleted]
Hi Tony,
I agree to the usual convention.
Only for this matter I need to tweak the code style to another kind of
style. And then I need to have the , between two spaces.
My vim-script relies on that.
Rgds,
Jeri