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

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

Re: indent-according-to-mode


From: kala
Subject: Re: indent-according-to-mode
Date: Wed, 2 Aug 2006 04:39:31 -0700 (PDT)

Hi Gary Wessle-2.

I'm writing Linux kernel level c-code, and thus have to use Linux kernel
indentation (8 characters.) I'm using GNU Emacs 21.4.1, and the following
works for me. Write in the .emacs-file:

;; use Linux kernel style (indendation of 8 characters etc.) for all C like
languages.
(defun my-c-mode-common-hook ()
  (c-set-style "linux"))

;; Add a hook to common mode.
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

;; Bind F5-key to indent a region of code according to the current
indentation style
(global-set-key [f5] 'indent-region)

Now in emacs you can indent a region by moving to the beginning of the
region and pressing CTRL + SPACE and then moving to the end of the region
and pressing F5.

Following indentation styles are available:
bsd, cc-mode, ellemtel, gnu, java, k&r, linux, python, stroustrup, user,
whitesmith.

Hope this was a useful piece of advice to you.
-- 
View this message in context: 
http://www.nabble.com/indent-according-to-mode-tf2029327.html#a5612101
Sent from the Emacs - Help forum at Nabble.com.





reply via email to

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