Strip trailing whitespace in emacs

Just installed WP-Syntax, a WordPress plugin for highlighting code. The first test will be this short elisp code I wrote to strip trailing whitespace from all lines in a file.

(defun strip-trailing-ws ()
  "Strip trailing whitespace from all lines"
  (interactive)
  (let ((cur (point-marker)))
    (goto-char (point-min))
    (while (re-search-forward "[ \t]+$" nil t)
      (replace-match "" nil nil))
    (goto-char (marker-position cur))))
Posted Tuesday, August 26th, 2008 under programming.

Tags:

Comments are closed.