On 4/9/07, Steve King steve@narbat.com wrote:
On Sat, 7 Apr 2007, Simon Strandgaard wrote:
Still, any ideas how to jump between beginning of line and beginning of text ? (aka. smart-home in the pc world)
Here's a command that will do the trick. If the cursor is at the beginning of the line it gets moved to the first non-whitespace character. Otherwise it gets moved to the beginning of the line.
[snip]
Ah, nice.
I have modified it slightly so that it first jump's to the the text-beginning and afterwards to the line-beginning.
#! /usr/bin/ruby line = ENV['TM_CURRENT_LINE'] index = ENV['TM_LINE_INDEX'].to_i
# extract leading whitespace remain = line.sub(/(^[ \t]*)/, '') whitespace = $1
if index == whitespace.size whitespace = '' else line = remain end
# place cursor print "#{whitespace}${1}#{line}"