I want to replace all adjacent spaces with one space but the replacement should only take place if they aren't at the line begin.
For example (I use brackets to demarcate line begin and end):
[Hello, world! ]
should be replaced with
[Hello, world! ]
but
[ Hello, world! ]
should become:
[ Hello, world! ]
I've tried the following command:
.s/\v([^\s])(\s){2,}/\1\2/g
But it replaces leading spaces too. I'm not sure why it's applied to leading spaces. Because I explicitly tell vim to replace only those adjacent spaces who follow a non-whitespace character ...[^\s]...
Or is the line begin character ^
considered as a character and I've to involve it either?
Ok, I also tried this one but without success:
.s/\v([^\s^])(\s){2,}/\1\2/g
So I'm lost here...