Posts Tagged ‘textmate’

TextMate: Setting The Default Language

Tuesday, May 20th, 2008 at 5:06 pm

It took me forever to figure out what the dropdown at the bottom of the TextMate window is called - you know, the one where you select the language you want to use. As it turns out, “language” would have been a good starting point in the Google, but it took me a while to figure that out. It’s the one that says “Blog - Markdown” in this screenshot:

TextMate Screenshot

Anyway, I wanted TextMate to default to Markdown instead of Plain Text, and once I figured out what to search for, I found my answer pretty quickly.

To find the UUID for Markdown, I did this:

% cd /Applications/TextMate.app/Contents/SharedSupport/Bundles/Markdown.tmbundle/Syntaxes/
% plutil -convert xml1 Markdown.plist 
% grep -A1 uuid Markdown.plist 
    <key>uuid</key>
    <string>0A1D9874-B448-11D9-BD50-000D93B6E43C</string>

And once you’ve got that, this line sets the default:

% defaults write com.macromates.textmate OakDefaultLanguage 0A1D9874-B448-11D9-BD50-000D93B6E43C

Disclaimer: I don’t know if the UUID is specific to Markdown, or to Markdown on my machine. I would recommend running those first three commands first and double check the UUID before you try to do this. The UUID is specific to Markdown, so you can just execute that last defaults write line (thanks Drew!)

Also, blogging from TextMate is pretty handy. You may have noticed that the screenshot includes the beginning of this post, because I was writing it just then, right in TextMate. Handy, I tells ya.

The Editors I Have Known And Loved

Monday, May 19th, 2008 at 6:57 pm

Most of the text I edit is code. It’s just part of being a web developer. Sure, I do a little writing now and again for this here blog, but I usually do that in a web browser, so most of the time I spend in text editors is for code. But, I’m working on a pretty big documentation project for work, and I’m trying out Markdown for blog posts, so I’m spending more time in a plain vanilla text editor to do both.

These are the text editors I’ve come to know and love.

Notepad

Everybody starts with Notepad. I think I wrote all of my HTML and fledgling Javascript in Notepad back in high school - Dreamweaver just felt unwieldy, and I didn’t know about any other options at the time.

UltraEdit

It’s been a long time since I’ve used UltraEdit, but it was my go-to editor for most of college. I really only used it because I could open several files in tabs - pretty standard these days, but that was the first time I’d seen it. I don’t even know what else it was capable of, because I just used it as a basic text editor.

Zend Studio

Zend Studio has been my primary IDE since I started my current job two and a half years ago. I love it because of the code completion and debugging for PHP, but I wind up using it for just about any text I need to edit quickly while I’m working because it’s always open. I also use it on my MacBook if I’m doing stuff for work.

TextMate

TextMate has been gaining ground in my workflow. It’s a pretty powerful little editor, but I barely take advantage of it. I use it all the time to edit plain text, but I almost never code in it - Zend is a far superior IDE for PHP, so it never made sense to use TextMate for it.

The real power in TextMate comes from its bundles. I just finished a project with Code Igniter (more on that in another post soon), and TextMate turned out to be a lot more useful thanks to the Code Igniter TextMate Bundle (for the record, I found a second bundle when trying to find the link to that one, but I haven’t tried it yet). I like Zend’s code completion, but I was able to develop in TextMate a lot quicker with the shortcuts provided by the bundle.

It also has a Markdown bundle, which adds some keyboard shortcuts, provides a quick cheat sheet, and makes it easy to preview while you’re writing. In fact, I’m writing this in TextMate right now.

Update: I love it even more now that I’ve watched this video about blogging in TextMate. You can post new entries and edit existing ones right in TextMate!

WriteRoom

To be honest, I haven’t actually written anything in WriteRoom, except for the couple of times I’ve played with it to tweak the font and such. Basically, it gives you a solid black screen with a narrow column of simple green text and a blinking console cursor. The colors can be customized, of course, but the point is that it gives you a stripped down, no frills, typewriter-like interface where you can write without the distraction of menus, bouncing dock icons, or IM windows. It really makes me wish I had something to write, because it just compels me to spill everything into words on the screen. I thought I might start using it with Markdown to write blog posts and stuff, but that was before I found all the shortcuts in TextMate. Still, WriteRoom just begs to be used, and I wish I had more than two days left in my trial so I could see if I can’t find a use for it.

CakePHP: First Impressions

Sunday, February 25th, 2007 at 12:22 am

About a month ago, I spent some time (more than I should have, really) getting Ruby on Rails running on my laptop so I could run through this tutorial on Apple Developer Connection. Ruby on Rails has been heralded as The Next Big Thing for about a year now, and I figured it was time to get on board. After all, PHP developers are most likely to switch, so I had to give it a shot.

I understood the concepts, but the fact that I’ve never even seen Ruby code (let alone written it) made it a little hard to follow. Was I willing to learn a new language to use the framework? If it would save me time in the long run, sure. But, at this point, I don’t really feel like I have a lot of time to be putting into new languages. I wanted the ease of development without such a heavy time investment upfront.

Thus: CakePHP. I know PHP. I’m reasonably comfortable with the MVC framework. And, as it turns out, Cake is real easy to set up. Their manual could use a little work - a lot of it was “Scaffolding makes things easy!” rather than “This is how you set up scaffolding.” Thankfully, the blog tutorial was more helpful than the rest of the manual (the parts I’ve read, anyway), and there’s a fairly significant Cake community writing articles and how-to’s all over the place. I later found out that scaffolding DOES make things easy (if not pretty) - I created a users table, two files with under a dozen lines of code between them, and I’ve got a super-basic user management utility. Obviously, I won’t be using it in the real world, but for quick prototyping or a basic placeholder for more advanced functionality, it’s great.

So that’s good news. I think I’ll be using it for that project after all. And, putzing around with it this afternoon taught me a few other new things. I had been meaning to set up a Subversion repository somewhere for a while now. In the past, I’ve used RCS for a few projects so I could roll back code if I screwed it up good, but it’s a pretty crappy solution. I spent about ten minutes trying to find SVN server software for the Mac before it occurred to me to just try svnadmin create /svnroot. I also found the language association drop-down in TextMate - it’s right there at the bottom of the window, by the way - so now it knows my .thtml Cake view files are actually PHP and colorizes appropriately.

I didn’t get much code written today, but I’m in a better position to get more done from here on out - I’ve got a good framework, a code repository, and I’m becoming more comfortable with my editor. Sometimes, you just need to take a day for all this extra crap, so that the coding part goes a little quicker and a little smoother.

And now, if you’ll excuse me, I’m going to crash. I slept about ten hours last night and took a three-hour nap this afternoon when I had a bad headache, and in spite of all that, I’ve had trouble keeping my eyes open for the past hour. I really hope it’s not my turn to get sick.

PHP, Zend, TextMate, and Code Completion

Tuesday, February 20th, 2007 at 10:40 pm

I spend most of my day coding PHP, so Zend Studio is like my Holy Grail. I had never even heard of it until i started my current job; we got it shortly after I started, and I’ve used it daily since.

The wonderful thing about Zend is its code completion. If I type strp, it will suggest strpos and strptime. When I hit Enter or Tab to select strpos, it finishes the function name, adds parenthesis, and in a little box above the code, it tells me strpos(string $haystack, mixed $needle [, int $offset]). And it’s the greatest thing ever.

I know how to program, and obviously, I know how to program in PHP, or else I wouldn’t be doing it for a living. However, there are very few compelling reasons to know every built-in function and the arguments they take; it’s far more important to know what that function does and what it will return. I know what strpos() does, and I know that it will return a boolean FALSE if $needle isn’t found in $haystack, and that it can also return 0 (which evaluates to FALSE) if $haystack begins with $needle.

Knowing these details is important, but I use strpos infrequently enough that I can never seem to remember whether $needle or $haystack is the first argument. With Zend, I don’t even need to think about it, so I can focus instead on what I’m doing, what variables I’m using, and what code needs to come next.

Of course, I don’t even really need to remember what variables I’m using, since Zend knows those, too. It also builds an index of all functions, classes, variables, and defines that I’VE written - not just the built-in ones - so I don’t need to remember much of that, either. Obviously, it’s quicker if I’m familiar with them and don’t have to rely on auto-complete for everything, but it sure as hell helps. How often is the source of frustration a $filename where it should have been $fileName? In Zend, I type $filen-tab, and it capitalizes the N and finishes the variable name for me.

Some programmers would argue that this isn’t “real” programming, since I’m relying on the software to tell me what to do. Some programmers would argue that the first group of programmers is a bunch of self-righteous Linux geeks and why don’t they just move out of their mom’s basement fer crissakes. I, of course, am in the latter camp.

Zend has significantly improved my productivity by allowing me to keep programming without switching over to documentation very often. Everyone has to RTFM every now and again, but the less I have to do it, the faster I can get things done. Even with the code hints, I still need to check php.net a few times a day (for example: the arguments for str_replace are $search, $replace, and $subject - is $search the thing I’m looking for, or the thing I’m searching through?)

Now, Zend isn’t all puppies and rainbows. It’s based on Eclipse, which was built in Java, which I’ve never had much luck with. On my PC at work, it’s a memory hog, and on my iBook, it’s barely usable. My work machine is pretty beefy, so it’s really not a problem there, but working from my Mac can be a real pain. On top of the speed issue, the fonts occasionally get messed up: the cursor appears somewhere it isn’t, so keystrokes affect some other area on-screen. I haven’t figured out what causes it, but I have to restart Zend whenever it happens (which leads me to another gripe: Zend takes forever to start).

Enter TextMate. Mac-happy developers have been in a tizzy about it for a few months now, but I finally started playing with it a couple weeks ago. It’s fast. It seems to be stable. The open-file tabbing is much better than Zend on the Mac. And, if you run it from Terminal with mate dirName/, it will load that directory (and any new files created in it while TextMate is open) into it’s file browser thingy. Zend has a similar file browser, but it’s not file system-aware (is that a real phrase, or did I make it up? Either way, you know what I mean).

However, it too has its downfalls. It doesn’t support open/save over FTP. And, much more importantly, it doesn’t do code completion.

I did find a PHP code-completion bundle, which has helped a bit. I type strp, and when I hit Escape, it suggests strpos (another Escape, and I get strptime). It’s a start, but it doesn’t know anything about arguments. You can hit Shift+F1 to go to the PHP manual for a function, but who wants to keep going back and forth like that? Furthermore, it’s only good for built-in functions - no functions I define, and no variables.

My TextMate trial ran out today, so I coughed up the $50 for a license. I’m hoping that I’ll find a bundle (or something) to soothe my code-completion addiction, but even if I don’t, it’s a good editor. In the meantime, I’ll probably commit more argument details to memory and get used to visiting php.net. I’m starting to do more development on my laptop (another big help: MAMP), so I think it’s going to be worth it.

Plus, that’s $50 I can write off come tax time next year. Right?