 <p>Your regex works. There are no spaces left at the end of the line after you run it. </p> <p>What you probably see is the "residual" incremental highlighting that would go away if you used<br> <code>:%s/[ ]\+$//g</code>. — Note the <code>\+</code> instead of the <code>*</code>. the incremental highlighting remains because <code>*</code> <em>always</em> matches, even with zero spaces.</p> <p>To remove the highlighting, type <code>:noh</code> (short for <code>:nohlsearch</code>).</p> <p>FYI: <code>:%s/[ ]*$//g</code> is equivalent to <code>:%s/ *$//g</code>.</p>