September 18, 2009

Emacs tips and tricks: Whitespace removal

The artist mode of Emacs can be used to remove the whitespaces in an Emacs buffer. This can be done as follows:

1. Add the following lines of code to your .emacs file

(defun clean-whitespace()




Now bind this function to a keyboard shortcut of your choice. I personally chose f6, so in the case of f6 add the following lines to your .emacs file

(global-set-key [f6] 'clean-whitespace)

This shall be enabled the next time you run emacs.

If you wish to update it in your current session, then open the .emacs file. Select the lines of code added and execute M-x eval-region.

No comments: