matthew ephraim

Archive for the ‘textmate’ Category

Textmate Paste History

Saturday, December 15th, 2007

TextMate has a neat paste history feature that allows you to stack copied text in a queue and then paste the text back into the editor sequentially or out of order.

To try it out, select a section of text and choose “Copy” from the Edit menu or hit Command + C (⌘C). Then select another section of text and copy again. Now you have two items in the queue. To paste the first item the queue, choose “Paste” from the Edit menu or hit Command + V (⌘V). This is the normal pasting behavior that you’re probably used to.

To take advantage of your pasting history, choose “Paste Previous” from the Edit menu or hit Shift + Command + V (⇧⌘V). You have now pasted the very first item that you copied, and the paste history has moved backward in the queue. So, if you were to choose the regular paste command again, it would paste the first item in the list, instead of the second.

To move forward to the second item again, hold the option key and choose “Paste Next” from the Edit menu or hit Option + Command + V (⌥⌘V). Now the second item has been pasted and the queue has moved back to the second item again.

Now let’s say that, instead of 2 items in your list, you had 10 items in your list. You probably wouldn’t want to move backward and forward through the whole list of items every time you wanted to paste something. From the Edit menu choose “Paste From History” or hit Ctrl + Option + Command + V (^⌥⌘V). You should be presented with a menu like the one below.

Scroll through the list and paste hit return to paste one of the items from the queue.

Textmate quickie: CSS opacity

Sunday, November 11th, 2007

Opacity using CSS isn’t supported very well in every browser (particular with one Internet “exploration” themed browser). It’s possible to get opacity right if you know the right people, but personally, I can never remember exactly what I need to do to make it work. Tonight, I was about to look it up once again, but I decided to see what Textmate would do if I typed “opacity” and hit tab, the usual bundle activation key. Sure enough, when I hit tab, Textmate responded by giving me this:

CSS
opacity: 0.5;
-moz-opacity: 0.5;
filter:alpha(opacity=50);

Not only did Textmate give 3 different options for making opacity work, when I changed the first 0.5 value to something else, the other 2 values changed as well. Textmate to the rescue again!

Textmate word completions or almost Intellisense™

Saturday, November 10th, 2007

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.

Textmate Hyperlink Helper Menu

Tuesday, October 30th, 2007

The Hyperlink Helper menu is another fun bundle that I had never noticed in TextMate.

Ctrl + Shift + L - Wraps the selection in an anchor tag with a default href attribute, pretty simple.

The real interesting stuff is the Google and Yahoo web lookups:

Ctrl + Shift + Apple + L - Performs a Google search for the selection and links to the first result found

Even better:

Ctrl + Shift + Y - Pops up a menu with 4 different Yahoo search options. Then performs your selected search and pops up a menu with the option to link to any of the top 10 search results.

Align Assignments in TextMate

Saturday, October 27th, 2007

This is a cool feature that I didn’t realize TextMate had until today. Say you have a series of assigmnents like this:

var administrator = "Dave";
var guest = "Matt";
var blocked = "Tim";

And you want to have all of the assignments aligned. Select the code and hit Apple + Option + ]. It will automatically align the statements like this:

var administrator = "Dave";
var guest         = "Matt";
var blocked       = "Tim";

I love you TextMate.