Find spaces in Vim Find leading spaces ^\s*[ ] The square brackets around the space are not needed, except here to avoid a trailing space. Remove trailing spaces :%s/\s\+$//g