Wednesday, April 6, 2011

Tabs in HTML mode in emacs.

So I've started using emacs and I love it. However, I'm a tab person. Unless I'm working on a project that is already using spaces, I use tabs. I mostly do php and html work. I've got tabs in php working well. But I can't figure out how to have html mode use tabs instead of two spaces.

Here is what I have so far:

(setq c-default-style "python")
(setq-default c-basic-offset 4
        tab-width 4
        indent-tabs-mode t)

What can I set so that html mode will use tabs?

Edit: Using Emacs 22.3.1

From stackoverflow
  • (add-hook 'html-mode-hook
              (lambda()
                (setq sgml-basic-offset 4)
                (setq indent-tabs-mode t)))
    
    Echo : Could I be doing something wrong? That code has no effect for me. Running Emacs 22.3.1 btw.
    Sean Bright : Are you using the html-mode that is shipped with emacs or a third party one?
    Echo : Just the default html-mode that is shipped with emacs.
    Sean Bright : Try with the edit I just made.
    Echo : Yup. It works now. Thanks for that.
  • actually, indent-tabs-mode should probably be t by default.

    Try M-i, just for a lark. That should insert a tab character. It's not a GREAT Solution, but it might work in a pinch.

    ALSO, how did you test for space vs tab? moving across it? or deleting it? you might have 'backward-delete-char-untabify' rearing it's head.

    Echo : Yup, I had already tried killing and reopening the buffer and restarting emacs.

0 comments:

Post a Comment