I get this:

#3
00
00
#4
11
10
#5
11
00
How I can put spaces between numbers in same rows?

Looks like you omitted spaces between the "\2" and "\3" and between the "\4" and "\5" in Alan's solution (or my 2nd one that broke out each piece individually) The final replacement should read

    /#\1\r\2 \3\r\4 \5/
            ^      ^

with the two marked spaces. If you prefer tabs, you can change those spaces to "\t" or just type a <tab> character there.


Or, if you already have the file, and there's only the two characters (0|1) on each line of interest, you can post-process it with

    :v/^#/s/./&\t

:v      on every line that doesn't match
^#      with a "#" at the beginnof the line
s       substitute
.       the first character you find
&\t with that character followed by a tab

(you can change the "\t" to a " ", but it doesn't show up quite as nicely in the email :)

I'm not sure why ":%s" didn't work, but ":g/./s" did work for you...they should be effectively the same: with ":%s", if the match isn't found on the line (which is the case for lines that don't match "."), it skips the line. Peculiar. I suspect either an incomplete spec (the file wasn't what I copied&pasted from the original posting) or you have a funky mapping that was interfering (starting vim with "vim -u NONE" and then trying the examples we gave may solve matters). Or, alternatively, our one-line examples got copied over wrong or munged by mailers along the way.

-tim





Reply via email to