Skip to content

Instantly share code, notes, and snippets.

@letuananh
Created January 11, 2017 06:53
Show Gist options
  • Save letuananh/1fffac24e1d0a76892d39d0509a8c7d4 to your computer and use it in GitHub Desktop.
Save letuananh/1fffac24e1d0a76892d39d0509a8c7d4 to your computer and use it in GitHub Desktop.
How to use web-mode.el in Emacs
;; download web-mode.el from http://web-mode.org/ and save it to ~/.emacs.d/custom-mode
;; (You may need to create that directory)
;; Add these following lines to ~/.emacs
(add-to-list 'load-path "~/.emacs.d/custom-mode")
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
;; Indentation for web-mode.el
(setq web-mode-markup-indent-offset 2)
(setq web-mode-css-indent-offset 2)
(setq web-mode-code-indent-offset 2)
;; [3] Now restart Emacs, edit an HTML file and then M-x RET web-mode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment