rossbar
9/18/2015 - 5:39 PM

Vim remove trailing whitespace

Vim remove trailing whitespace

Remove trailing whitespace

  • From a current line:
:s/\s\+$//
  • From entire file:
:%s/\s\+$//

Explanation:

  • % = from whole file

  • s = search and replace

  • \s\+$ = regex searching for spaces til the end of a line

  • / = replacement value (empty string)

Source: http://stackoverflow.com/questions/3474709/delete-all-spaces-and-tabs-at-the-end-of-my-lines