分页: 2 / 2

发表于 : 2007-04-24 21:43
fhqijeg
gg=G

Emacs+Astyle

发表于 : 2007-07-01 22:19
haoeng
装一个Astyle
再在Emacs里添加以下

(defvar astyle-command "astyle --style=ansi --mode=c")

(defun astyle-region (start end)
"Run astyle on region, formatting it in a pleasant way."
(interactive "r")
(save-excursion
(shell-command-on-region start end astyle-command nil t)
)
)

(defun astyle-buffer ()
"Run astyle on whole buffer, formatting it in a pleasant way."
(interactive)
(save-excursion
(astyle-region (point-min) (point-max))))

(add-hook 'c-mode-common-hook
'(lambda ()
(define-key c-mode-map "\C-cr" 'astyle-region)
(define-key c-mode-map "\C-cb" 'astyle-buffer)
(define-key c++-mode-map "\C-cr" 'astyle-region)
(define-key c++-mode-map "\C-cb" 'astyle-buffer)))

Astyle的参数你可以根据需要自己改,我是从一个外国朋友的Blog上找的,很好用
Emacs里直接 Ctrl+C B就OK