Chinaunix首页 | 论坛 | 博客
  • 博客访问: 641190
  • 博文数量: 154
  • 博客积分: 8323
  • 博客等级: 中将
  • 技术积分: 2060
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-13 02:17
文章分类

全部博文(154)

文章存档

2011年(2)

2010年(117)

2009年(5)

2008年(30)

分类: LINUX

2011-01-13 09:35:13

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)
阅读(1869) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~