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

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

Re: Indentation.


From: Sam Peterson
Subject: Re: Indentation.
Date: Fri, 27 Oct 2006 09:53:21 -0700
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin)

>>>>> "zombek" == zombek  <zombek@gmail.com> writes:

    > Hi.  I'm new to emacs and I'd like to set 2 things: 1) 4 space
    > indentation (no mather which language) and it shouldn't care
    > about the syntax - when I say indent then indent 2)when I press
    > RETURN when beeing on some indentation level i should
    > automatically go to the same indentation level in the new line
    > without the need to press TAB

(setq-default indent-tabs-mode nil)
(global-set-key "\C-m" 'newline-and-indent)
(global-set-key "\C-m" 'newline)

For cc-mode and modes derivative of cc-mode, the following will set
indentation to 4 spaces:

(setq c-basic-offset 4)

For the same modes, this will turn off syntactic indentation (electric
parens and braces).

(setq c-syntactic-indentation nil)

For other languages I'm not sure.  I always saw syntactic indentation
as a useful feature.  If you absolutely want TAB to indent 4-spaces
regardless, try this:

(fset 'four-space-indent "\C-u ")
(add-hook 'c-mode-hook
    (lambda () (local-set-key [tab] 'four-space-indent)))

Use other hooks for other language modes.

HTH.

-- 
Sam Peterson
skpeterson At nospam ucdavis.edu
"if programmers were paid to remove code instead of adding it,
software would be much better" -- unknown


reply via email to

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