- Using multi-web-mode
- Using web-mode-el
Using multi-web-mode: It is a very easy and simple way to configure emacs. One just needs to configure their preferred modes in their .emac files like this:
(require 'multi-web-mode) (setq mweb-default-major-mode 'html-mode) (setq mweb-tags '((js-mode "<script[^>]*>" "</script>") (css-mode "<style[^>]*>" "</style>"))) (setq mweb-filename-extensions '("htm" "html" "phtml")) (multi-web-global-mode 1)
Note: Also if you want to configure emacs for editing HTML files containing other Languages like PHP you can simply include PHP tag description also into the “setq mweb-tags”.
Multi-web-mode: Below is a simple step to Install. Open your .emacs file and add the below code over there.
(require 'multi-web-mode) (setq mweb-default-major-mode 'html-mode) (setq mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>") (js-mode "<script[^>]*>" "</script>") (css-mode "<style[^>]*>" "</style>"))) (setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5")) (multi-web-global-mode 1)
Also, if we talk about the Usage of the Multi web mode, then it basically binds the following keystrokes:
- M-<f11>: This stroke prompts the user to override the default major mode.
- M-<f12>: This stroke prompts the user to override the calculated extra indentation.
Web-mode-el: One can use this by:
(require 'web-mode) (add-to-list 'auto-mode-alist '("\\.html$" . web-mode))
Output: Below is the output for the same.