Hi,
Does TextMate have a keyboard shortcut that acts_as Vim's "^" key? i.e: it puts the cursor in front of the first character of a line that is not a space or a tab.
On 18.09.2008, at 15:21, Thomas wrote:
Hi,
Does TextMate have a keyboard shortcut that acts_as Vim's "^" key? i.e: it puts the cursor in front of the first character of a line that is not a space or a tab.
Simply record a macro with:
APPLE+ARROW_LEFT OPTION+ARROW_RIGHT
save it and bind it to whatever.
--Hans
That has a slight problem when your line does begin with "non word" chars (i.e: - _ ....)
I have a "smart home" command bound to the "Home" key. Repeated presses get you to the "smart" home and the "real" home.
Input: Selected Text or Line Output: Insert as Snippet
#!/usr/bin/ruby line = ENV['TM_CURRENT_LINE'] index = ENV['TM_LINE_INDEX'].to_i
# extract leading whitespace remain = line.sub(/(^\s*)/, '') whitespace = $1
if index == whitespace.size whitespace = '' else line = remain end
# Escape anything in the line that might be mistaken # as a snippet token. line = line.gsub(/([$\`])/){"\#$1"}
# place cursor print "#{whitespace}${1}#{line}"