|
|
|
Re: Tabs instead of spaces in Java editor, how? [message #548104 is a reply to message #548038] |
Tue, 20 July 2010 16:32 |
|
<Religious Issue>
If your source is going to be viewed by others, you really ought to use spaces.
Different folks in different viewers WILL have different tab widths. Code with tabs invariably looks horrible to someone. Spare the rest of the world a little eye strain. Use spaces.
Or face excommunication from the Church of That Egotistical Nutjob Guy Over There!
</Religious Issue>
Adjusting the indentation may not "unify" the whitespace, but reformatting it should. ctrl+shift+F I believe.
And I believe in spaces. Tabs are for unlettered barbarians and heretics. Spaces are the one true path to universal code formatting. Embrace the Space.
Okay, I'll stop now.
--Mark Storer
Senior Software Engineer
Autonomy Cardiff
import legalese.disclaimer;
Disclaimer<Cardiff> disCard = null;
Google Code Search
[Updated on: Tue, 20 July 2010 16:36] Report message to a moderator
|
|
|
Re: Tabs instead of spaces in Java editor, how? [message #548112 is a reply to message #548104] |
Tue, 20 July 2010 16:40 |
|
On 7/20/2010 10:32 AM, Mark Storer wrote:
>
> If your source is going to be viewed by others, you really ought to be
> using spaces.
>
> Different folks in different viewers WILL have different values for
> their "tab width". Code with tabs invariably looks horrible to someone.
> Spare the rest of the world a little eye strain. Use spaces.
>
> Or face excommunication from the Church of That Egotistical Nutjob Guy
> Over There!
> [/Religious Issue]
>
> Adjusting the indentation may not "unify" the whitespace, but
> reformatting it should. ctrl+shift+F I believe.
> And I believe in spaces. Tabs are for unlettered barbarians and
> heretics. Spaces are the one true path to universal code formatting.
> Embrace the Space.
>
> Okay, I'll stop now.
Mark,
I see you probably grew up next door to the Tab family and their boys
beat you up at the flagpole after school every day!
:-)
Russ
|
|
|
Re: Tabs instead of spaces in Java editor, how? [message #548115 is a reply to message #548112] |
Tue, 20 July 2010 17:16 |
|
Thanks for bringing up the painful memories. Fortunately they had "beat up kids smaller than you" classes immediately after school on Wednesdays. The down side was that they had some new tricks to try out every Thursday.
--Mark Storer
Senior Software Engineer
Autonomy Cardiff
import legalese.disclaimer;
Disclaimer<Cardiff> disCard = null;
Google Code Search
|
|
|
|
Re: Tabs instead of spaces in Java editor, how? [message #548692 is a reply to message #548624] |
Thu, 22 July 2010 16:39 |
|
Unclean! Unclean!
Quote: | What's more scrolling through heavily indented code padded with spaces is wrist slittingingly tiresome.
|
You don't use CTRL+arrow, do ya? Give it a shot. Heathen.
Quote: | If you use tabs for indentation all users can configure their IDE to represent that as 2 spaces or 4 spaces or whatever according to their individual preference. If you use spaces for indentation then everybody is screwed and forced to look at whatever your idea of nice indentation looks like which likely varies from person to person and is at least partly dependent on how much horizontal screen real estate you have.
|
Okay, technically you're right... UNTIL:
private final static int SOME_CONST = 0;
private MyLongTypeName = new MyLongTypeName();
public int foo = 42;
Code formatted like this is flat out easier to read.
That first "= alignment" is probably one tab, for everyone.
The second one is 16 spaces. It could be between 8 and 4 tabs depending on who first spaced it out.
The third? More... don't feel like counting any more.
So if a 2-spaces=1-tab person originally formatted the code, and a 4-spacer opens the file, it'll look Horribly Wrong. Ditto going the other way.
Basically, as soon as a tab appears after a fixed-length character or characters (spaces, variable names, whatever), Mr Tab is a Bad Idea.
Which happens in javadocs all the time:
/**
* Witty and insightful commentary.
* @param foo Short description.
* @param bar Really long description. I mean like... LONG. "So
* long it wraps down to the next line" long. We're talking
* LONG! Did I mention it's long?
*/
The auto-formatter will do this for (or "to") you.
So what I'm trying to say is this: You're wrong. Furthermore, you almost certainly have some odious personal habits that should not be discussed in a professional forum such as this. In conclusion, you blow goats.
CTRL+SHIFT+F is great. IIRC, there's a Magic Comment you can insert to convince eclipse to leave the commenting of a particular section of code alone... AHA!
stick "@formatter:off" and "@formatter:on" inside your comments to control it. Spiffy. Found that one in "Java development user guide > Reference > Java Editor > Formatter". I'd be stunned if it wasn't java-specific.
--Mark Storer
Senior Software Engineer
Autonomy Cardiff
import legalese.disclaimer;
Disclaimer<Cardiff> disCard = null;
Google Code Search
[Updated on: Thu, 22 July 2010 16:48] Report message to a moderator
|
|
|
Re: Tabs instead of spaces in Java editor, how? [message #548774 is a reply to message #548624] |
Thu, 22 July 2010 23:06 |
|
On 2010.07.22 7:56, Neutrino wrote:
>
> CTRL-SHIFT-F to reformat the document. That's a life-saver many thanks.
>
> P.S. If you use tabs for indentation all users can configure their IDE
> to represent that as 2 spaces or 4 spaces or whatever according to their
> individual preference. If you use spaces for indentation then everybody
> is screwed and forced to look at whatever your idea of nice indentation
> looks like which likely varies from person to person and is at least
> partly dependent on how much horizontal screen real estate you have.
> What's more scrolling through heavily indented code padded with spaces
> is wrist slittingingly tiresome.
> Tbh anyone who uses spaces for indentation should be hanged, or at least
> sterilized so they can't pass on the degenerate genes :)
>
> That is all.
While I generally like tabs as a great idea, I must nevertheless point
out that this advice ONLY works for leading tabs. Subsequent tabs (and I
use such to align variables AFTER their types, so between types and
variables) will never look good except with the space-width of the
original author.
When sharing code, always and only the space, sadly, never the tab.
Russ
|
|
|
Powered by
FUDForum. Page generated in 0.09099 seconds