On 4/9/07, Steve King <steve(a)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.
I have modified it slightly so that it first jump's to the the
text-beginning and afterwards to the line-beginning.
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 = ''
line = remain
# place cursor