Emacs: Force emacs to use tabs

1907阅读 0评论2011-01-13 _lovelinux
分类:LINUX

Problem

You want to force emacs to use tabs instead of always replacing everything with spaces.

I admit it, i'm a tab nazi. I like tabs and would rather indentation done with tabs than spaces. It's annoying as hell to have to hit back-space 8 times just to move the cursor back one indent level. Plus, i think that the default emacs auto-indentation is usually not how i format my code (i.e. 2-spaces per indentation level when i normally use 1-tab=8-spaces).

Solution

Make emacs insert an actual TAB character when you hit the TAB key rather than "indent"ing the line. I've used this solution with '', but i dont see any reason why it shouldn't work with more modes.

Edit your .emacs file

Place the following lines in your ~/.emacs file:
;; Turn on tabs
(setq indent-tabs-mode t)
(setq-default indent-tabs-mode t)

;; Bind the TAB key
(global-set-key (kbd "TAB") 'self-insert-command)

;; Set the tab width
(setq default-tab-width 4)
(setq tab-width 4)
(setq c-basic-indent 4)
上一篇:学象棋该读哪些书?
下一篇:博客已升级,请注意变更地址