Textmate, open file at Caret

Posted by amjags on Stack Overflow See other posts from Stack Overflow or by amjags
Published on 2009-12-01T07:50:21Z Indexed on 2011/01/06 9:54 UTC
Read the original article Hit count: 198

Filed under:

I bet this is really obvious but I can't find how to open the linked file that the Caret is currently on in Textmate. For example in the likes of Dreamweaver you can click in the index.html portion of <a href"index.html" hit cmd-D and it opens this file in a new tab. Is this possible?

Would also be good to do this with <img src="image.jpg" to open the file directly into Photoshop.


Solved! Solution for Patrick below.

I used a modified version of Daustin777's example above to create a Command called OpenatCaret. The command is: open "$TM_PROJECT_DIRECTORY"/"$TM_SELECTED_TEXT"

I then extended this by installing a macro which allowed you to select a path between double quotes but not including the quotes. I got this from the macromates board here. http://lists.macromates.com/textmate/2009-June/028965.html

To wrap them both together I put my cursor in a path and recorded a new macro where I run the "Select within double quotes" macro and then the OpenatCaret command. I then named this OpenProjectFileAtCaret and bound this macro to cmd-D.

Works a treat and is used all the time. Just make sure you have the correct default apps setup for each file type you are opening eg. Textmate for php, asp, html and it will open them in a new tab.

© Stack Overflow or respective owner

Related posts about textmate