Advertisement
Guest User

Untitled

a guest
Dec 16th, 2021
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.71 KB | None | 0 0
  1. #!/usr/bin/env ruby18 -wKU
  2.  
  3. # If there’s a selection, output that twice (as a snippet)
  4. # leaving the duplicate as the new selected text.
  5. # Otherwise split the current line around the caret and
  6. # output “right, left” to duplicate the line, leaving the
  7. # caret in the same place on the new line
  8.  
  9. require File.join(ENV["TM_SUPPORT_PATH"], "lib/exit_codes.rb")
  10. require File.join(ENV["TM_SUPPORT_PATH"], "lib/escape.rb")
  11.  
  12. if ENV['TM_SELECTED_TEXT'] != nil
  13.     TextMate.exit_insert_snippet(e_sn(ENV['TM_SELECTED_TEXT']) + "${0:" + e_snp(ENV['TM_SELECTED_TEXT']) + "}")
  14. else
  15.     col   = ENV['TM_LINE_INDEX'].to_i
  16.     TextMate.exit_insert_text(ENV['TM_CURRENT_LINE'][col..-1] + "\n" + ENV['TM_CURRENT_LINE'][0...col])
  17. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement