Does emacs have a built in function for removing trailing spaces in a buffer? I want to remove trailing whitespace at the end of all the lines in a buffer.
According to the EmacsWiki,
M-x delete-trailing-whitespace will eliminate all trailing whitespace in a buffer. In Spacemacs, it is bound to
SPC x d w by default
You can do it automatically for all buffers by adding the following to your
(add-hook 'before-save-hook 'delete-trailing-whitespace)
For future reference, you can search for Emacs functions within Emacs by typing
M-x apropos, then typing your query. In this case,
M-x apropos <RET> whitespace <RET> provides a list of functions relating to whitespace.