I've noticed some programmers do not seem to have much desire to write clean, organized, and readable code. What are some good ways to encourage consistent indentation, good naming of variables and functions, organized file structures, among other things?
Personally, I would give them someone else's badly written code, and ask them to explain. However, since you said fellow programmers, I am guessing you are not the supervisor.
Mandatory code reviews, coding standards, and if they have to read part of your code, give them some horribly written code one time, and let them decipher...
Mandate (or encourage your boss to mandate) peer code reviews. At the very least, have another programmer skim written code at some point. This also gives your company more chances to catch more bugs before they bite some one.
You could get them to work on legacy code, so that they feel the pain of trying to change sloppy code.
You could also have an approval system, where they are not allowed to work on anything new untill their code is approved.
Another way is those who write the best code get to work on the most interesting projects.
Lead by example.
Become a champion of the patterns and standards that work for you.
Code reviews.
Suggest books that you've found helpful and that promote neater code.
Be blunt; I tell team members all the time what I like and don't like about their code. More importantly, I tell them why.
EDIT: I ask for code samples in the beginning of the interview process. Pretty code doesn't always mean a great developer, but sloppy, unreadable code is never the mark of a good engineer.
I may be a little picky; I'm the guy who spell checks code comments.
The only way you get away with writing unreasonably difficult code is if one of two conditions exist:
You write the code, throw it over the wall to QA/support/whoever, and never have to see it again once it works the first time ("mostly").
You are a Vulcan and can read/fix anything you've ever written, and because you are the only one who ever develops within that code you get away with it.
To improve readability, ensure that neither of these conditions exist. The best way to do that is never to let somebody work alone. This way, the path of least resistance is to produce code that at least one more person can read. The programmer in question probably dislikes all-the-time fighting about his code even more than he dislikes paying attention to readibility.
In the (odd) case where the developer refuses to work with anyone else and their unreadable code continues to cause problems, fire them, because they are not a valuable asset.
The idea of mandating code readability is kind of perverse. The carrot is more valuable than the stick, and if you give an engineer rules, they'll spend all their time finding loopholes instead of actually contributing value.
Engage the staff. Don't do anything to publicly humiliate them (come on who does that!?, jim no need to reply), but do encourage them. Positive reinforcement works way better than negative.
Sure lead by example, but take the time out of your day to work with the people that need the help. Give people goals.
Don't just say "it's the rule. If you don't do it we'll make you eat toothpaste with a toothpick".
We (developers) are logical. And, if a developer cannot understand the logic of code readability, especially when talked to by a manager/higher up, maybe something has to change, and that's for those involved to decide.