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.
Input: Selected Text or Line Output: Insert as Snippet
----- Cut Here ----- #! /usr/bin/perl
$line = $ENV{'TM_CURRENT_LINE'}; $column = $ENV{'TM_COLUMN_NUMBER'}; $whitespace = '';
if ($column == 1) { # Chop leading whitespace from the line and # place it into its own variable. $line =~ s/^([ \t]*)//; $whitespace = $1; }
# Escape anything in the line that might be mistaken # as a snippet token. $line =~ s/([$\`])/\\1/g;
# Print the line as a snippet. The cursor will be # placed at the ${1} token. printf '%s${1}%s', $whitespace, $line;
----- Cut Here -----