3

I've used UltraEdit for years and never had a problem with sharing code with fellow developers whether they worked on Windows, Mac, Linux, Eclipse, Visual Studio -- what have you...

But now I am in an office where some developers are using emacs and they complain profusely about the white space differences my code "introduces". I have UltraEdit set to write to files as UNIX-style (no Windows returns), but it seems the whitespace renders differently for the emacs developers.

Since I don't use emacs (or vi), its a pain for me to try to figure out why this is impacting them, but I more so just want them to shuttup! lol

This is even causing problems in SVN/Diff!

Any thoughts on how to fix this?

Forget about everyone using Emacs because thats not gonna happen lol.

qodeninja
  • 530

6 Answers6

13

You fix this by creating a standard style guide for your organization's code. Everyone then configures their editors to match that style guide. For example you choose either tabs or spaces for your indentation and how wide indentations should be. This eliminates inconsistencies in and makes it so there is no arguing about code formatting, because the answer should be in the style guide. Ideally you would also have a tool that ensures code matches the style guidelines before it is checked in. For an example, see google's C++ Style Guide

4

At a guess - because I've been there a couple of times - I would check what settings you are using for tabs, tab width and indentation in UltraEdit.

Some editors tend to be clever and compress spaces into tabs either while editing or when saving a file. If you don't have the same settings for saving tabs/spaces and tab width as your fellow developers this can cause all sorts of funny behaviour, both when it comes to viewing the file in a different editor and in a diff tool. I've got some prime examples here in some code that was edited by someone who couldn't be bothered to turn off the space->tab conversion on save.

Timo Geusch
  • 2,773
2

The tools available to you depend on the IDE you're using. VS and/or ReSharper in the .NET world can automatically enforce and convert whitespace differences or other "non-compliant" formatting, such as intercepting "tabs" and replacing them with 4 spaces, and converting existing tabs in the code. I'm sure UltraEdit has similar functionality if it is, as they claim, "the world's best hex/text editor". If it doesn't, there should be some plug-in that can normalize whitespace formatting.

And I really think Bernard's suggestion is the best solution; majority rule, choose a single development environment and standardize the set of tools.

KeithS
  • 22,282
2

You probably have your IDE configured wrong for your work environment. Given you have no standards to work to, and anarchy reigns supreme (Implied by the existence of this question) you should configure your IDE to leave everything alone, except the lines you edit. I expect a tool such as Multiedit has this capability.

It is your responsibly not to change white space needlessly. I have learned (the hard way) this requires discipline and attention to detail, as well as an ability to leave things alone that are ugly, but not broken. It's not ideal, but without a guiding standard, all you will get into is pointless, destructive religious debate over whats right and wrong.

In the large (multi million line) code base I work on, as a rule changing code that does not need changing is wrong, and that is everything in the file - tabs, line ends, end of line spaces. The amount of merge conflicts that occur when pointless (white space, layout, comments etc) changes occur is an expensive waste of time and effort. You can, with decent tools, mitigate this to some degree, but never completely.

Ultimately, try to agree to a standard format, and also a migration part towards that standard for legacy code. Preferably use tools to support (if not enforce) the chosen standard. (We have not been able to agree to this, the money men would rather pay for the hidden costs of not doing it)

mattnz
  • 21,490
1

The best solution is to use code formatter on check in. Strip trailing blanks, replace spaces with tabs.

Ide's always wreak havoc. But not using one, IMHO, is couter-productive nowadays.

Coder
  • 6,978
1

You may consider using emacs solely for the indentation and formatting after you have done all of your other changes. I've done this before myself, because I actually like how emacs indents. I would make all changes in my IDE (Qt Creator, Kate, or KDevelop), then I would open it up in emacs and select all and put in some command to auto-indent everything. I don't remember the commands, but if it is something you are willing to do, I'm sure your fellow emacs users would be glad to help you with the commands.

Chance
  • 521