Question

What Visual Studio settings and .emacs macros improve the likelihood that code written on Windows (in visual studio) will still look good in Emacs (and vice versa)? I've recently taken to turning off tabs in emacs (so tabs are rendered via spaces) and this at least makes the code look the same (tho people who like certain tab sizes are out of luck). Is there a better way?

Was it helpful?

Solution

Always use tabs for indenting only and nothing else, and there's no problem.

Anything involving aligning characters across lines (not indenting) should use spaces.

Just do that, then people can set their tab size to whatever they like, and everything will all be fine.

OTHER TIPS

Tab sizes is a purely personal preference, but each piece of code or project should specify which tab size it wants to use as a standard. That way, even if someone doesn't like your tabs sizes, they'll know you meant it to be that way and do the same in any fixes, and hopefully they shouldn't have a problem with that.

Emacs's idea of tabs is that they're a compression scheme, that they're always size 8, and they're normally a different size from the indent size. This leads to things like it indenting 4 spaces at the first indent, then 1 tab at the next, then 1 tab and 4 spaces at the third indent level.

Your options for making it compatible with a variable-sized tab editor are to set emacs to spaces (like you did), or set its indent size to 8 (this is what they do in the linux kernel source), or to hunt down the emacs macro file which makes it have variable sized tabs ( I have seen it on the web, but I didn't make a bookmark).

In addition to using spaces instead of tabs and making sure that the tab width is the same in both editing environments, I usually change emacs's (because I'm more familure with it) c/c++ modes to "bsd" style. This seems to more closely match visual studio's default style.

From my .emacs custom-set-variables list:

'(c-default-style (quote ((c-mode . "bsd") (c++-mode . "bsd") (java-mode . "jav
a") (other . "gnu"))))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top