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

Tabs under Emacs

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

If you intended to correct an error in the post then please contact us.

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 this post

Link to post
Share on other sites
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


Share this post

Link to post
Share on other sites
Guest Anonymous Poster
Keeping tabs (as in, tab characters) to a minimum really is a good idea. [url=]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)))

Share this post

Link to post
Share on other sites