all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* how to change the indentation style of emacs
@ 2011-01-22 15:22 Anand Dhanakshirur
  2011-01-23 12:56 ` suvayu ali
  0 siblings, 1 reply; 6+ messages in thread
From: Anand Dhanakshirur @ 2011-01-22 15:22 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,
I am using emacs for c and c++ files.

1. Presently(default), In a C program,
after "for" loop, the next line(the next line starting with
"{" is indented(shifted) by 2 spaces.
I want to change this.
I want the next line is not shifted by 2 spaces when i press TAB key.(for indentation)
basically
Now it is, for (i=0;i<10; i++)
             {
             }

I want this to be changed as 
           for (i=0; i<10;i++)

2 .One more thing want to do.
after opening for loop of if condition,
the next line is getting shiftedby 2 spaces.
I want the next line to be shifted by 4 spaces.

How to do these 2 things?



      



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to change the indentation style of emacs
       [not found] <mailman.23.1295774749.8897.help-gnu-emacs@gnu.org>
@ 2011-01-23  9:37 ` rusi
  0 siblings, 0 replies; 6+ messages in thread
From: rusi @ 2011-01-23  9:37 UTC (permalink / raw)
  To: help-gnu-emacs

On Jan 22, 8:22 pm, Anand Dhanakshirur <adhanakshi...@yahoo.com>
wrote:
> Hi,
> I am using emacs for c and c++ files.
>
> 1. Presently(default), In a C program,
> after "for" loop, the next line(the next line starting with
> "{" is indented(shifted) by 2 spaces.
> I want to change this.
> I want the next line is not shifted by 2 spaces when i press TAB key.(for indentation)
> basically
> Now it is, for (i=0;i<10; i++)
>              {
>              }
>
> I want this to be changed as
>            for (i=0; i<10;i++)
>
> 2 .One more thing want to do.
> after opening for loop of if condition,
> the next line is getting shiftedby 2 spaces.
> I want the next line to be shifted by 4 spaces.
>
> How to do these 2 things?

Have you seen and tried http://www.emacswiki.org/emacs/IndentingC
(especially different styles)?


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to change the indentation style of emacs
  2011-01-22 15:22 Anand Dhanakshirur
@ 2011-01-23 12:56 ` suvayu ali
       [not found]   ` <102513.20309.qm@web30901.mail.mud.yahoo.com>
  0 siblings, 1 reply; 6+ messages in thread
From: suvayu ali @ 2011-01-23 12:56 UTC (permalink / raw)
  To: Anand Dhanakshirur; +Cc: help-gnu-emacs

On Sat, Jan 22, 2011 at 4:22 PM, Anand Dhanakshirur
<adhanakshirur@yahoo.com> wrote:
> Hi,
> I am using emacs for c and c++ files.
>
> 1. Presently(default), In a C program,
> after "for" loop, the next line(the next line starting with
> "{" is indented(shifted) by 2 spaces.
> I want to change this.
> I want the next line is not shifted by 2 spaces when i press TAB key.(for indentation)
> basically
> Now it is, for (i=0;i<10; i++)
>             {
>             }
>
> I want this to be changed as
>           for (i=0; i<10;i++)
>
> 2 .One more thing want to do.
> after opening for loop of if condition,
> the next line is getting shiftedby 2 spaces.
> I want the next line to be shifted by 4 spaces.
>
> How to do these 2 things?
>

You can choose indentation styles by using `C-c . <RET> STYLE <RET>'
where style can be tab completed. For more details you can look in the
info manual section 26.3.5 (Programs > Program Indent > Custom C
Indent > Customising C Indentation). If nothing suits you, I think you
can even define your own style.

-- 
Suvayu

Open source is the future. It sets us free.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to change the indentation style of emacs
       [not found]   ` <102513.20309.qm@web30901.mail.mud.yahoo.com>
@ 2011-01-24  8:07     ` suvayu ali
       [not found]       ` <577605.6548.qm@web30901.mail.mud.yahoo.com>
  0 siblings, 1 reply; 6+ messages in thread
From: suvayu ali @ 2011-01-24  8:07 UTC (permalink / raw)
  To: Anand Dhanakshirur; +Cc: Emacs mailing list

Hi Anand,

On Mon, Jan 24, 2011 at 4:56 AM, Anand Dhanakshirur
<adhanakshirur@yahoo.com> wrote:
> Dear suvayu ali,
> Thanks for the reply,
> I tried C-c . <RET> (ctrlc .) it is not working, it is "it is undefined"
>

Sorry about that, I should have checked myself. the manual has a typo.
The command is just
`C-c .' This will prompt you for the c indentation style you want to
use. You can see all the built in styles by hitting the TAB key. try
them out, if you feel none of them does what you want, you can
customise and write your own style.

For more detailed information look in these sections of the info manual page:
1. <http://www.gnu.org/software/emacs/manual/html_node/emacs/Custom-C-Indent.html>
(this has the key binding typo, the rest I think is okay)
2. <http://www.gnu.org/software/emacs/manual/html_node/ccmode/Customizing-Indentation.html#Customizing-Indentation>

Good luck.

-- 
Suvayu

Open source is the future. It sets us free.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to change the indentation style of emacs
       [not found]       ` <577605.6548.qm@web30901.mail.mud.yahoo.com>
@ 2011-01-24 14:43         ` Suvayu Ali
  2011-02-07 20:22           ` PJ Weisberg
  0 siblings, 1 reply; 6+ messages in thread
From: Suvayu Ali @ 2011-01-24 14:43 UTC (permalink / raw)
  To: Anand Dhanakshirur; +Cc: Emacs mailing list

On Mon, 24 Jan 2011 05:37:16 -0800 (PST)
Anand Dhanakshirur <adhanakshirur@yahoo.com> wrote:

> hi,
> C-c . is not working, but, M-x c-set-style is working.
> What is the piece of code to set it permanently in .emacs file?

(define-key global-map (kbd "C-c .") 'c-set-style)

> Thanks


-- 
Suvayu

Open source is the future. It sets us free.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to change the indentation style of emacs
  2011-01-24 14:43         ` Suvayu Ali
@ 2011-02-07 20:22           ` PJ Weisberg
  0 siblings, 0 replies; 6+ messages in thread
From: PJ Weisberg @ 2011-02-07 20:22 UTC (permalink / raw)
  To: Emacs mailing list

On Mon, Jan 24, 2011 at 6:43 AM, Suvayu Ali <fatkasuvayu+linux@gmail.com> wrote:
> On Mon, 24 Jan 2011 05:37:16 -0800 (PST)
> Anand Dhanakshirur <adhanakshirur@yahoo.com> wrote:
>
>> hi,
>> C-c . is not working, but, M-x c-set-style is working.
>> What is the piece of code to set it permanently in .emacs file?
>
> (define-key global-map (kbd "C-c .") 'c-set-style)
>
>> Thanks

I think you might be looking for:

M-x customize-group <RET> C

Or possibly just

M-x customize-option <RET> c-default-style



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-02-07 20:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.23.1295774749.8897.help-gnu-emacs@gnu.org>
2011-01-23  9:37 ` how to change the indentation style of emacs rusi
2011-01-22 15:22 Anand Dhanakshirur
2011-01-23 12:56 ` suvayu ali
     [not found]   ` <102513.20309.qm@web30901.mail.mud.yahoo.com>
2011-01-24  8:07     ` suvayu ali
     [not found]       ` <577605.6548.qm@web30901.mail.mud.yahoo.com>
2011-01-24 14:43         ` Suvayu Ali
2011-02-07 20:22           ` PJ Weisberg

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.