Hello all,
I'm writing a command to mimic eclipse's semicolon insertion. In Eclipse, when you press ';' it looks for a semicolon at the end of the line; if there is one already there, you get a ';' at your cursor (as if you had typed it normally); if not, it puts it in the proper position at the end of the line, and your cursor is at the end of the line.
With the following command, TextMate will put the semicolons in the desired place, but the cursor doesn't move, which is annoying.
input: selected text or line output: replace selected text activation: key equivalent ';' scope: "source"
#!/usr/bin/env ruby
$t = STDIN.read
if $t =~ /\A(.*);\Z/ $c = ENV['TM_LINE_INDEX'].to_i print $t.insert($c, ';') else print $t+';' end
Any idea how to move the cursor? Snippets handle cursor motion, but I'm not sure I can get the semicolon to go to the right spot. Ideas? Tricks?
Best, Kevin