emacs写html,能不能自动缩进?
能不能像写c一样有格式化的功能?
所有mode的自动格式化功能都是C-M-\, 或者M-x indent-according-to-mode
(defun indent-buffer ()
"Indent current buffer."
(interactive)
(indent-region (point-min) (point-max))
(delete-trailing-whitespace)
(unless indent-tabs-mode (untabify-buffer))
(message "Buffer indented: %s" (buffer-name)))
有html-mode的,网上找找很多的
写html的3个mode差不多了
html-mode
css-mode
javascript-mode
我使用的是web-mode
;; web-mode
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.css\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.js\\'" . web-mode))
(require 'web-mode)
(setq web-mode-markup-indent-offset 2)
(setq web-mode-css-indent-offset 2)
(setq web-mode-code-indent-offset 2)
- 用html-mode,按Control-j换行,就会自动缩进。
- 对于格式不统一的html源文件,
C-x h
选中整个文件, 按 TAB,就会把整个文件的格式调整好。