#### Archived

This topic is now archived and is closed to further replies.

# Tabs under Emacs

This topic is 5801 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, Does anyone know how to force emacs to allow more than 1 tab per line? For example, I would like to be able to be able to do: inti;// my comment When editing C code. If possible, I would like to be able to use tabs outside of cc-mode, as well. I''m trying to emulate a set up somewhat similar to what simple editors like MS-DOS Edit and Notepad allow for. Thanks in advance. --- Bart

##### Share on other sites
We prefer that you use spaces to align your code, so we write software that makes it impossible to use tabs...

Actually, you''d have to edit the C-mode and C++-mode definitions (probably written in elisp). Grep the web; you''ll find something.

##### Share on other sites
quote:
Actually, you''d have to edit the C-mode and C++-mode definitions (probably written in elisp). Grep the web; you''ll find something.

I already tried searching around, and I did find some information which seemed to be relevant -- basically just some C-mode additions to my .emacs file, but they really didn''t accomplish what I wanted.

It''s actually unimportant whether or not the tabs get converted to spaces (as in MS-DOS Editor) or remain tab characters; I just need to be able to indent my code properly (and this includes using tabs at the end of lines.)

BTW, the example code I types in didn''t turn out right, it should have read:

{tab}int{tab}i;{tab}// my comment

I''ll keep Googling in the hope that something turns up. Maybe it would just be more productive to write a portable MS-DOS Edit clone

---
Bart

##### Share on other sites
C-q TAB

"When you know the LORD you have no need for masturbation!"

##### Share on other sites
Keeping tabs (as in, tab characters) to a minimum really is a good idea. [url=http://www.jwz.org/doc/tabs-vs-spaces.html]Here''s why[/url]. That said, the easiest way to make the TAB key insert a TAB instead of executing the "reindent the current line" command is to put
(define-key global-map "\t" ''self-insert-command)
in your .emacs file. This will change the behavior of tab in every mode that doesn''t do a major overhaul of how tab works (in particular, it works in C/C++-style modes, but not in Lisp-style modes).

Another way to do it, with more control, is to use the hook facility to specify what modes you want the broken tab behavior in:
;; Make TAB insert a TAB character in the "C common" modes (c, c++, etc)(add-hook ''c-mode-common-hook	  ''(lambda ()	     (local-set-key "\t" ''self-insert-command)))

1. 1
Rutin
25
2. 2
JoeJ
20
3. 3
4. 4
5. 5

• 9
• 9
• 46
• 41
• 23
• ### Forum Statistics

• Total Topics
631749
• Total Posts
3002054
×