Emacs indentation for html (web mode) does not work properly

I’m using web-mode in Emacs to get syntax highlighting and indentation for PHP and HTML.

If I have this code in a .php file

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

And then put the cursor on the middle line and press tab then nothing happens.

I want it to look like this:

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

If I put the text in a tag on a single line and try to indent, it works.

This:

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

turns into this, which it should

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

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)

try put these setting in a 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)
Hello, buddy!稿源:Hello, buddy! (源链) | 关于 | 阅读提示

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 前端开发 » Emacs indentation for html (web mode) does not work properly

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录