开发者

Applying cleanups in Emacs?

I have enabled several C cleanups for Emacs by setting the c-cleanup-list variable, and then enabling electric and auto-new开发者_如何学Pythonline modes. Unfortunately, this only formats the code as you're typing it. I would like to format code that has already been written. Is there a quick way to do this?

Cheers!


I employ a simple cleanup function:

(defun cleanup-buffer ()
  "Perform a bunch of operations on the whitespace content of a buffer."
  (interactive)
  (indent-buffer)
  (untabify-buffer)
  (delete-trailing-whitespace))

that I've assigned a global keybinding to:

 (global-set-key (kbd "C-c n") 'cleanup-buffer)

You can put your cleanups in a similar function and invoke it instead. You can also make Emacs trigger such a function on buffer save(or some other event) - have a look at the after-save-hook.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜