How do I configure Emacs HTML mode to behave like the default HTML package TextMate?

My friend is considering switching to Emacs from TextMate. It is used in the default HTML editing mode of TextMate, which has 4-space tabs and inserts tab characters (i.e., it does not auto-skip by default). It also allows you to complete open HTML tags with " Cmd-Shift->". Any ideas?

+3
source share
2 answers

I think these settings should do the trick:

(defun my-html-mode-hook ()
  (setq tab-width 4)
  (setq indent-tabs-mode t)
  (define-key html-mode-map (kbd "<tab>") 'my-insert-tab)
  (define-key html-mode-map (kbd "C->") 'sgml-close-tag))

(defun my-insert-tab (&optional arg)
  (interactive "P")
  (insert-tab arg))

(add-hook 'html-mode-hook 'my-html-mode-hook)

An explanation of the settings in is 'my-html-mode-hookas follows:

  • set bookmark width to 4
  • Insert force tabs (as opposed to spaces)
  • TAB, ( ,
  • 'sgml-close-tag - , close , .

, , TAB TAB, . , 'self-insert-command ( ).

'html-mode-hook. ( html-), , 'eval-after-load. .

+9

emacs HTML , :

  • Emacs , .

  • Emacs , ( tabify untabify). buffer-local tab-width. M-x set-variable, (setq...), .

  • , indent-line-function tab-to-tab-stop, tab-stop-list (4 8 12 16...) indent-tabs-mode t.

indent-tabs-mode Emacs . tab-to-tab-stop - , , , tab-stop-list 4.

, , , "C-c C-e", , . sgml-close-tag, C-c /

: , , 8.

+2

Source: https://habr.com/ru/post/1710766/


All Articles