On Jul 8, 6:47 pm, Tony Mechelynck
<[email protected]> wrote:
> On 05/07/09 16:15, Jeri Raye wrote:

> > 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

> 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.

I once played with the convention of using spaces both before
and after.  In the end, though, it looked to wierd, even to me.
(The rationale was simple, the comma isn't any more "attached"
to what precedes it than it is to what follows, so the spacing
should be the same.)

> 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.

It will.  This can be fixed with a second step:
    :%s/,\s*,/,,/g
(or whatever is actually desired).

--
James Kanze (GABI Software)             email:[email protected]
Conseils en informatique orientée objet/
                   Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to