Two nice text editors
Let’s just start this off with a bang: If you’re doing more than occasional PHP editing in the WordPress editor, you’re doing it wrong.
Why ANY editor is better than the WordPress editor:
- No Undo! (This should sell it right away…)
- No line numbering. (Just about any error message will give you a line number to investigate.)
- Easy to save multiple versions.
- Easy to edit several files at once.
Luckily, there are several free editor tools that work well…
Notepad++ This editor, like many free, open source tools, is sublime in its simplicity. It’s a small program, is simple to run (download it wherever you want, double-click it) and the interface is nice and simple. For all those people who like the simplicity of the Windows Notepad, but just wish there were a few more niceties, like line numbering and code highlighting, this tool is for you. It launches just as fast as Notepad, and I appreciate the fact that it’s all in one folder. (It makes me much more likely to try a program when I know it’s not mucking about in the Windows registry.)
It’s simple and straightforward, but you can extend it pretty far with plugins. A couple of plugins I would recommend are Compare and Zen Coding. Compare will make it very easy to compare two documents to highlight the changes made between versions. (“You mean you didn’t document everything you changed??”) Zen Coding is a very extensive plugin that makes writing HTML very quick and easy. (You essentially write HTML shorthand that looks sort of like a CSS selector, then use a keyboard shortcut to expand it into well-formatted HTML.)
Notepad++ has been my favorite editor since I heard about it at WordCamp Philly, though I have recently been trying out “PDT” or “PHP Development Tools” which is really itself an add-on (libraries and such) for Eclipse, another code editor. I’ve just started trying PDT, but the main thing that it offers above Notepad++ is PHP code hinting. A lot of the code-test-fix-test-fix-test cycle is consumed by stupid syntax mistakes, where I’ve forgotten exactly how to form an if function_exists statement or similar. Hopefully PDT can make a dent in these errors and make PHP writing much faster. (Of course, PDT doesn’t have all of the WordPress functions loaded into it, just the standard PHP ones, so there are plenty of times I still have to reference the WordPress Codex to figure out the proper syntax.)
While gathering the URLs to link in this article, though, I think I may have seen a PHP library for Notepad++, which is so far the main advantage of PDT. We’ll see how this pans out.
PHP Development Tools (AKA “PDT” or “Eclipse-PHP”) This tool, created by Zend to apparently show off their skills with PHP and also tempt people to buy their Zend Studio product, is a very full-featured PHP IDE (Integrated Development Environment). In other words, it’s more than just a text editor (even one on steroids, like Notepad++), it includes error checking, code hinting, breakpoints, file management and a bunch of other features.
I’ve actually just started using PDT, and it’s very nice (also available for Mac), but I haven’t completely transitioned from Notepad++. (This might be largely due to the fact that I can right-click a file and open it in Notepad++, but I’m also familiar with that interface already.) One thing that could be the compelling reason to get me to switch is the code hinting. Besides offering up suggestions about PHP functions I may want (based on what I’ve started typing), just the added bonus of automatically closing brackets for me when I start the brackets. There is a lot of repetition in code writing, so anything that can reduce that repetition by just including the repetitive stuff is a bonus.
The WordPress editor is okay for a quick change, but no more than that. This isn’t the Wild West: NO COWBOY CODING!
(Definition of a “Code Cowboy”. Scroll down to #7.)