help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: No automatic tabs in Emacs?


From: Bob Proulx
Subject: Re: No automatic tabs in Emacs?
Date: Thu, 2 Dec 2010 10:40:09 -0700
User-agent: Mutt/1.5.20 (2009-06-14)

Sueroski wrote:
> And I'm flustrated about one think... so, I'm programmer (mainly
> Python and PHP) and actually all editors gives me automatic adding
> tab... I haven't this on Emacs and I don't know how to do it. I must
> on every line press TAB and it's not good ;[
> So... what I must change to have auto tabs in Emacs? I searched most
> of sites but everything telling how to select type of tabs, leight
> of tabs etc.

I think the default expectation is that instead of pressing Enter
(also known as C-m the carriage return character) that if you press
C-j you will get what you want.  The C-j (the newline character) is by
default bound to newline-and-indent.  Try using C-j instead of Enter
and see if that does what you want.

You can change your keymap so that Enter (C-m) also calls
newline-and-indent just like C-J and automatically indents the next
line for you.  Set up a hook for the modes you care about and change
the keymap.

(add-hook 'c-mode-hook
            '(lambda ()
                 (define-key c-mode-map "\C-m" 'newline-and-indent)))

Change the above as appropriate for the other modes you wish to use.

I used to always map C-m to newline-and-indent.  But more recently
have been using random unconfigured machines and don't get my normal
customizations.  I have therefore trained myself to use C-j now
instead since that is a default behavior and doesn't need
configuration.

Bob



reply via email to

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