[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changing the behaviour of <tab>

From: Jonas Steverud
Subject: Re: Changing the behaviour of <tab>
Date: Sat, 14 Sep 2002 10:59:29 +0200
User-agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.1 (sparc-sun-solaris2.8)

"Kristoffer" <address@hidden> writes:

> How do one change the behaviour of the <tab> key, from
> doing nothing but remove indentation to
> actually indent properly ?

What is happending is that the tab key is bound to a function which
interprets the contents of the buffer and indents to a certain level -
all depending according to some rules.

To take Lisp as an example (I don't know Python so I can't make a
Python example):


And now press tab on each line in a buffer where emacs-lisp-mode is
active, say *scratch* (where lisp-interaction-mode is active but
that's just a detail in this context), and the result is:


If I understand you correctly, what you want is


There are two ways of solving this.

One is to understand the benefits of letting Emacs interpret the
contents of the buffer and maybe tweak the rules I mentioned above
(how to do that depends on the mode and I have no idea how to do it,
never done it - but ask here and people will help you). This is what I
would recommend. Just press tab and the line is indendet to either the
left or the right depedning on context. Other nice things to use is to
bind the enter key/return key to newline-and-indent (so you don't have
to press tab youself) and the indent-region function (mark a region
and do M-x indent-region to see what it does).

The other way of doing this is to bind tab to tab-to-tab-stop (which
is the function M-i is bound to, this is not the same thing as C-q tab
since the latter inserts the tab character).

Place this in you .emacs:

(global-set-key (kbd "TAB") 'tab-to-tab-stop)

To find out about which function a key is bound to, use C-h c and then
press the key. Or press C-h k and then the key to get a description of
the function. Press C-h C-h to get a list of the help functions.


(         !     Wei Wu Wei     )
(        Meaning of U2 Lyrics, Roleplaying        !  To Do Without Do  )

reply via email to

[Prev in Thread] Current Thread [Next in Thread]