[TxMt] Env vars

Thomas Aylott (subtleGradient) oblivious at subtlegradient.com
Mon Sep 3 18:05:09 UTC 2007


Take a look at how I do this in TextMate/Support/lib/codecompletion.rb
look at set_line! and caret_placement

You have to take into account that tabs are only a single character of  
variable width and that the current selection could have started from  
the left or right.

It really is way more complex than it should be, hopefully TM2 will  
make this simple.

	thomas Aylott — subtleGradient — CrazyEgg — bundleForge

On Sep 3, 2007, at 4:51 AM, Juan Falgueras wrote:

> 	Hi
>
> asking for help
>
> I have the next code for to eat the spaces behind the cursor (with  
> Shift and FwdDel).  My problem is I know only how to move around the  
> current line but not how to go beyond and eat also new lines in  
> order to reach the start of the next line.
>
> 	#!/usr/bin/env ruby
>
> 	sel = ENV['TM_SELECTED_TEXT']
> 	if sel != nil
> 	  sel = sel.dup
> 	  sel.gsub!(/\s/, '')
> 	  print sel
> 	  exit 0
> 	end
>
> 	left  = ENV['TM_CURRENT_LINE'][0, ENV['TM_LINE_INDEX'].to_i]
> 	right = ENV['TM_CURRENT_LINE'][ENV['TM_LINE_INDEX'].to_i .. -1]
>
> 	right.gsub!(/^\s+/, '')
>
> 	print left + right
>
> I have found the env vars
>
> 	TM_CURRENT_LINE'
> 	TM_LINE_INDEX
> 	TM_LINE_NUMBER
> 	TM_INPUT_START_LINE
>
> but it is not evident for me how to know the whole text before/after  
> the cursor.
>
> Any idea will be welcome.




More information about the textmate mailing list