English 中文(简体)
Textmate, open file at Caret
原标题:
  • 时间:2009-12-01 07:50:21
  •  标签:
  • textmate

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.

最佳回答

I don t have a full solution as a linked bundle but this should get you close.

You can use the Bundle Editor to create a command that will open an image if you select the path. Create a new command and enter this:

open "$TM_DIRECTORY"/"$TM_SELECTED_TEXT"

Set Input to Selected Text or Word
Set Output to Discard
Set Key Equivalent to an unused key combination.

Close the editor. Now you should be able to select an image path and it will open when you press the appropriate keyboard shortcut.

You can add the -a flag to the open command to specify which application to use to open the selected file. This is just a basic example and not an entire solution that will work with every type of file path.

You can get info on Textmate environment variables here.

问题回答

暂无回答




相关问题
Explain this Regular Expression please

Regular Expressions are a complete void for me. I m dealing with one right now in TextMate that does what I want it to do...but I don t know WHY it does what I want it to do. /[[:alpha:]]+|( )/(?1::$...

TextMate: Adding to a bundle

There are a couple of bundles that I would like to add some functionality to. If I update the bundles via SVN will my additions/updates be replaced?

Textmate and vim modes

It is possible to emulate vim modes, macros and bindings in textmate?

Textmate, open file at Caret

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 ...

Code folding on consecutive collect/select/reject/each

I play around with arrays and hashes quite a lot in ruby and end up with some code that looks like this: sum = two_dimensional_array.select{|i| i.collect{|j| j.to_i }.sum > 5 }.collect{|i| ...

git commit -a on Mac hangs when TextMate is quitted

I have core.editor set to "mate -w". On Leopard, git commit -a starts TextMate. After entering a commit log message, saving (Cmd-S), and quitting (Cmd-Q) TextMate, git would successfully complete the ...

热门标签