I've been bug fixing / enhancing some code that was written at different times by different people with different coding styles. It can get a bit hard to read the code at times. This is nothing new in Real World Software Development™, and common with code that has been touched by many people. Very common in projects that are made up of several open source projects - even if one project module dictates a coding style it could be different than another projects module (and few dictate a style). It's an interesting problem.
In my opinion though, aside from complete design differences, two of the hardest parts of reading Multi-Style Code™ are line endings and tabs for spaces.
I know most coders know what I am talking about, but for an example for non-coders. It would be like if I were to write the blog entries like this:
I
Would
like to co
nvey inform
ation to you
how efficient
is
this
now maintain
it!
I haven't gotten a fix for windows line ending yet - which make the code look like some one hit enter twice on every single line of code (and in this case windows line endings are the problem, because the server is Linux (and I develop on Mac) so windows line endings are incorrect IMO) - but Afae does show whitespace so it can help with the tab vs. space thing.
The only problem with showing whitespace is it slows down the editor. It doesn't make it unusable, just not as snappy as with it off. I found myself going into preferences, turning Show Whitespace on making a bit of code (or the file) uniform, then going back into preferences and turning it off when I was doing my actual code changes. It was kind of tedious but completely necessary if I am to understand what the code is doing and how to update it.
So with this update I added a quick button on the menu bar (and in the right click menu) to show and hide whitespace. It's a small change, but it has helped me out quite a bit, and if you are a spelunker as well you might find it useful. (there is also a toggle for the print margin, and a few bug fixes).
If anyone has an idea (or trick) on how to convert windows line endings to unix line endings from within Eclipse - a menu I don't know about or something - I'd dig knowing how you do it. Right now I am dropping to a shell and using tr.
I am not up for writing a generic auto code formatter, and I don't think a generic one exists, but if one exists …
You can download the latest Afae on the download page. These changes are in the afae_editor_nightly.
Technorati Tags: Afae, Code, Linux, Mac, Open Source, Python, Software, Web Applications
I use a find/replace within eclipse to rid my scripts of the \r(CR). Just check the Regular expressions box within the Find/Replace dialog and:
Find: \r(\n)
Replace with: $1
In eclipse 3.2.2, at least, you can change the line endings for a given file by going to Source / Cleanup Document, and then selecting the last checkbox and choosing your line ending format (dos/unix/mac). You might think that once a file had been converted to use a single line ending format, eclipse would figure that out and automatically use those same delimiters when you hit return, but you’d be wrong. For that kind of sophisticated editing capability you’ll need to upgrade to a more powerful editor, like vi.