How to replace only one whitespace in txt

I have some text (* mean whitespace)

-**asdasda*asdasdasd**asd*asd
-**asdasda*asdasdasd**asd*asd

i want to use '<,'>s replace all one whitespace to like

-**asdasdaasdasdasd**asdasd
-**asdasdaasdasdasd**asdasd

how to do that

You can do

:'<,'>s/[^ ]\zs \ze[^ ]//g

I assumed that by “whitespace” you meant blank, as per your example.

Here are some details:

  • [^ ] is the notation for "any one character but a blank
  • \zs means “the match we’re looking for starts after this”,
  • \ze means “the match we’re looking for ends before this”
  • Note that the match here is different than the search pattern, which is exactly what we want: We want the pattern to look for surrounding-nonblanks, but the match should only be the blank inside