matthew ephraim

Textmate word completions or almost Intellisense™

At work I use Visual Studio to develop web applications, and I’ve gotten very accustomed to using Intellisense. Perhaps, a little too accustomed. I’ve also been developing with PHP a lot on the side and I usually use Textmate. However, until recently, I hadn’t been using the word completion functionality that Textmate offers for PHP. It’s not exactly Intellisense, but it provides a lot of the same functionality and has really sped up my PHP development time.

There are two types of word completion that Textmate offers for PHP (that I know of). The first type allows you to type a word and then hit a key to scroll through a list of terms match that word. For example, let’s say I have a function in my class called “checkTheFrontDoor”. I don’t feel like typing that function name all the time. In Textmate I can type “$this->c” and then hit the esc key. The first time I hit esc, “$this->c” will change to “$this->checkTheBackDoor”, the name of another function in my class. That’s not what I want. So, I hit esc again. Now Textmate switches the text to “$this->checkTheFrontDoor”. That’s what I want, so I go ahead and keep typing. You can also use word completion to scroll through the names of variables that you have defined and to scroll through built in PHP functions that match the text you have entered.

The other type of word completion that Textmate offers is more similar to Intellisense. Let’s say I was looking for the name of the function that pushes an item onto an array. My guess would be that the function name starts with “array”, so I type “array”. If I just hit the esc key I can scroll through all of the built in functions that start with “array”. There are a lot of them though, so that could be tedious. Instead I can hit alt + esc and get a pop up menu of suggested function names. Even better, when I choose a function name, it will automatically give me a list of parameters that the function accepts. So, for example, if I type “array”, hit alt + esc and then choose “array_push” from the menu, Textmate gives me the following:

PHP
array_push(array stack, mixed var, [mixed ...])

Textmate gives me the name of the function and the parameters for the function and, like most bundles, it lets me tab through each parameter as I put in the values. As far as I can tell, Intellisense doesn’t give you the option of filling out the parameters, so, in some ways, Textmate’s word completion offers even more functionality.

Textmate offers word completion for many other languages in addition to PHP. If there’s a bundle for a language it probably has some form of word completion with the same esc and alt + esc key combinations. If you’re using Texmate for development, make sure to check if it has word completion for the language you’re developing with.

3 Responses to “Textmate word completions or almost Intellisense™”

  1. rob Says:

    Hi…just wondering if there is a way to get Textmate to do similar completions, but for PHP classes that are outside of the current file?

    Thanks for you tips here!

  2. Matthew Ephraim Says:

    I haven’t found a way to do it yet. That’s a feature that I would like as well.

  3. Bos Says:

    Thanks a lot! It helped me.

Leave a Reply