Advertisement

Tabs under Emacs

Started by August 29, 2002 04:02 PM
3 comments, last by trzy 22 years, 5 months ago
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
----Bart
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.
Advertisement
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
----Bart
C-q TAB

"When you know the LORD you have no need for masturbation!"
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
Keeping tabs (as in, tab characters) to a minimum really is a good idea. Here''s why. 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))) 

This topic is closed to new replies.

Advertisement