首页 > emacs写html,能不能自动缩进?

emacs写html,能不能自动缩进?

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)

【热门文章】
【热门文章】