[Top][All Lists]

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

Re: .emacs file to act like Visual C++

From: Alan Mackenzie
Subject: Re: .emacs file to act like Visual C++
Date: Sat, 31 Aug 2002 18:22:35 +0000
User-agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (Linux/2.0.35 (i686))

Ryan Boder <> wrote on Fri, 30 Aug 2002 17:26:42
-0400 (EDT):

> Hi, I am using emacs/g++ in a project where the other developers are using
> Visual C++. I would to have my c++-mode alignment and all be the same as
> theirs so that I can continue to do so.

> 1. Is there a .emacs file that is maintained or that some one on the list
> has that accomplishes this?

> or

> 2. The most important thing is that curly braces are aligned with if
> statements and for/while loops when placed on the line beneath them, not 2
> spaces over which is the default for emacs. Can some one tell me how to do
> that?

> Sorry if this is common knowledge, but I couldn't find the answer on the
> web.

This is one of these things 'most everybody needs to do.  The definitive
description is in the cc-mode Info page, to be found as follows:
C-h i                 will get you to info
m cc-mode             takes you to the cc-mode page
Select the item "customizing indentation", which will tell you everything
you need to know, and a good deal more besides.

It may well be that one of the predefined "styles" is what you need.
By the sounds of it, "bsd" style is likely just right, and something like
the following in your .emacs (taken from the cc-mode info page) would do
the trick:

     (defun my-c-mode-common-hook ()
       ;; use Bsd style for all C like languages
       (c-set-style "bsd")
       (setq tab-width 4) ; or whatever indentation level your project uses
       ;; other customizations can go here
     (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

All the best!

> Ryan

Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").

reply via email to

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