11

Background:

I'm primarily a Javascript developer. Espresso mode rocks.

I work on a team where other people touch my code (and I theirs). Different folks have different preferences for tab width. I like mine at four, a coworker likes his at two.

JSLint complains if you mix tabs and spaces (yes, I realize you can turn it off - but it helps keep me sane).

I'm staring at my buffer in whitespace-mode, and can clearly see that when I newline and tab, it inserts a bunch of tabs and then.. four spaces.

How can I prevent this behavior? The only whitespace before the first visible character of a line should be tabs...

donohoe
  • 13,867
  • 4
  • 37
  • 59
warfangle
  • 316
  • 2
  • 6

1 Answers1

1

You need to adjust a couple settings in your emacs configuration.

(setq tab-width 4)        ;; set your desired tab width
(setq indent-tabs-mode t) ;; use tabs for indentation

You may also need to adjust the indentation offset in your javascript mode so that each indent is a multiple of your tab width (for C-based modes it's called c-basic-offset).

Dave Bacher
  • 15,652
  • 3
  • 63
  • 86