5 ms·
One thing that's nice about being a programmer is that I haven't thought about any mechanics of text formatting for many years. When I save a file, it just get
by jrockway 7y ago
One thing that's nice about being a programmer is that I haven't thought about any mechanics of text formatting for many years. When I save a file, it just gets reformatted according to rules that were set up exactly once. I have no idea whether or not I use spaces or tabs, or whether there are semicolons at the end of lines, or whether it's "} else {" or "}\nelse {".
It makes me sad that the least technical users have to use the most primitive software tooling. Something that programmers never think about (because they are best equipped to program their own programming tools) is apparently something that results in national studies and extremely snide articles because nobody will make good tools for them that end the problem once and for all.
- johnday 7y ago> I have no idea [...] whether it's "} else {" or "}\nelse {". You never read your own code?
- MereInterest 7y agoFormat to personal style on open. Format to project style on save. The project style is then consistent, but irrelevant.
- rightbyte 7y agoI have tried this but the formater in Eclipse messes up too many edgecases or nicely column aligned struct definitions to make it work for me.
- AgentOrange1234 7y agoThis sounds good and might work for programmers who are working in well-established languages with mature tooling. For me, I’m opening so many kinds of text files, I’d need a parade of parsers and pretty-printers to pull it off. I can’t see it being a realistic option in the near term.
- bottle2 7y agoSame here. In a given week, I’ve opened files across 6 different {programming} languages
- quicklime 7y agoBeing a programmer won't save you from this particular style war. If there's a comment in your code with a sentence that begins with a double space, your code formatter probably won't flag or remove it in the same way that MS Word will. And it's likely shown in a monospace font, which makes it more noticeable. How many spaces do people put after a full stop in comments in their code? I go with one, but Vim's J and gq commands annoyingly insert two spaces when joining sentences from separate lines. I'd love it if someone could tell me how to fix this. Edit: found it, the command is "set nojoinspaces"
- ip26 7y agoBroadly speaking, internal consistency is the best & most important style. So just follow the convention of the codebase you are working in (ideally with a code formatter to help)
- taeric 7y agoIt is even more amusing in Java. Many folks essentially try to do markdown, not realizing that they are probably writing one giant paragraph.
- aembleton 7y agoI go for two, but that's only because it is now in my muscle memory to apply two spaces after a full stop. This came about when I was doing a typing certificate in the UK in the late 90s and I've continued to do it ever since.
- ken 7y agoYou have your text editor set up to use a formatter which handles the number of spaces after periods, in source code comments and plain text files? How?
- maxerickson 7y agoThis isn't the same kind of text formatting as that though.