In vi editor I want to replace next line char by space

in vi editor I want to replace next line char by space

help me

eg:
input:

123
123
123

output:

123 123 123

Esc + : and then..

 1,$ s/\n/ /g 

no it's not working

i am using SunOS

OS is not the issue...
Is the file created on the same system or is downloaded from another system? If later case, you may try 'dos2unix' on the file and then use the above command in vi.

You can also put the cursor on the first line and then type:

3J

if your lines are more than 3 then use the no. of lines in instead of 3J as Scrutinizer has said.