Emacs indent for html (web mode) not working properly

I use web-mode in Emacs to get syntax highlighting and padding for PHP and HTML.

If I have this code in a .php file

<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p> 

And then place the cursor in the middle row and click on the tab, after which nothing will happen.

I want it to look like this:

 <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p> 

If I put the text in the tag on one line and try to back out, it works.

It:

 <p> <a>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</a> </p> 

turns into this that should

 <p> <a>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</a> </p> 

My .emacs file

 (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 '("\\.jsp\\'" . 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)) (setq web-mode-markup-indent-offset 4) (setq web-mode-css-indent-offset 4) (setq web-mode-code-indent-offset 4) (setq web-mode-indent-style 4) 

enter image description here

+6
source share
2 answers

try putting these settings in the hook function:

 (defun my-web-mode-hook () "Hooks for Web mode." (setq web-mode-markup-indent-offset 4) (setq web-mode-css-indent-offset 4) (setq web-mode-code-indent-offset 4) (setq web-mode-indent-style 4) ) (add-hook 'web-mode-hook 'my-web-mode-hook) 
+5
source

Could you add this

 (add-to-list 'auto-mode-alist '("\\.php\\'" . web-mode)) 
0
source

All Articles