开发者

Prevent emacs from mixing tabs and spaces?

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 n开发者_StackOverflowewline 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...


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜