Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use emacs for c++ coding and in my project there are many people who use gvim for the same. My problem is when I open their .h or .cc files in emacs it's formatting became really bad, Its probably because of tab setting or something like that.
What I want is what should I put in my .emacs file such that it would format the code in nice usual way when I see it in emacs but does not disrupt it for my Vim friends.
Is it even possible or do I need to tell Vim guys to change something in their profiles too. We might try to enforce some regularity and may enforce reasonable profile features.

share|improve this question
Read this: Tabs versus Spaces: An Eternal Holy War. – RedGrittyBrick Oct 17 '11 at 9:49

If it is a matter of tabs you need to set tab-width variable in Options > Customize emacs menu, you'll be given the option to make that change permanent.

share|improve this answer

To really solve your problem you need to decide whether to use tabs or spaces in your project.

You should also decide how wide one tab character should appear.

There is an excellent VimCast regarding that topic.

share|improve this answer

Some Emacs hacker once wrote:

My opinion is that the best way to solve the technical issues is to mandate that the ASCII #9 TAB character never appear in disk files: program your editor to expand TABs to an appropriate number of spaces before writing the lines to disk. That simplifies matters greatly, by separating the technical issues … from the religious issue.

In my vim configuration I set et, ts=2, sw=2. If I used Emacs I would do the equivalent. When working with others on a project, standardised settings need to be agreed or mandated.

share|improve this answer

Most code editors have separate concepts of tab width and code indent width.

The project needs to agree on the indent size, and either: That TAB has the same size in all editors (usually 8 spaces, which was the mechanical implementation of TAB on teletypes and other mechanical terminals); or that indentation is never to include TABS, but only spaces.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .