Skip to content

Instantly share code, notes, and snippets.

@client9
Created June 13, 2016 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save client9/eeb9e905729a1ba182758e4febacd16e to your computer and use it in GitHub Desktop.
Save client9/eeb9e905729a1ba182758e4febacd16e to your computer and use it in GitHub Desktop.
emacs snippet for batch reformatting
(defun buffer-untabify ()
"Untabify an entire buffer"
(interactive)
(untabify (point-min) (point-max))
(delete-trailing-whitespace))
(defun buffer-indent()
"Reindent an entire buffer"
(interactive)
(indent-region (point-min) (point-max) nil))
(defun buffer-cleanup()
"Untabify and re-indent an entire buffer"
(interactive)
(if (equal buffer-file-coding-system 'undecided-unix )
nil
(set-buffer-file-coding-system 'undecided-unix))
(buffer-untabify)
(buffer-indent)
(delete-trailing-whitespace))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment