[TxMt] Open URL

Allan Odgaard throw-away-1 at macromates.com
Mon Dec 12 08:31:57 UTC 2005


On 12/12/2005, at 8:42, Freek Dijkstra wrote:

> In the mean time, is there a variable which returns the full word  
> at the place the caret is located, rather then the selected text?

TM_CURRENT_WORD but this is defined by word characters, so if this is  
to grab the URL you probably want to extract it from TM_CURRENT_LINE  
instead, using TM_COLUMN_NUMBER as the carets offset into the line.  
Using the regexp from the plain text grammar (to underline links) a  
command would be something like:

open $(perl -pe <<<$TM_CURRENT_LINE "s/.{0,$TM_COLUMN_NUMBER}((https?| 
ftp|mailto):\S+?)(?=[)>,.':;\"]*(\s|\$)).*/\$1/")





More information about the textmate mailing list