In a situation like this (pseudo code)
assert a_method(with, many, arguments)
I'd like to select the a_method(...)
part, launch a macro/command/whatever and get that :
variable = a_method(with, many, arguments)
assert variable
The tricky part is to have variable
as a selected default value that I could type over to change the current variable name on both lines.
I've seen Jim Weirich (within Emacs) and Gary Bernhardt (within Vim) do this many times, but I can't figure how to do this in Textmate.
Thanks for any help on this.
Thanks to James Edward Gray II, I've made some progress :
here is my command :
#!/usr/bin/env ruby -wKU
require File.join(ENV["TM_SUPPORT_PATH"], "lib/exit_codes.rb")
require File.join(ENV["TM_SUPPORT_PATH"], "lib/escape.rb")
if ENV['TM_SELECTED_TEXT'] != nil
col = ENV['TM_LINE_INDEX'].to_i - ENV['TM_SELECTED_TEXT'].length
TextMate.exit_insert_snippet("${1:variable} = " + e_snp(ENV['TM_SELECTED_TEXT']) + "\n" + ENV['TM_CURRENT_LINE'][0...col] + "${1/\s.*//}")
end
but from this :
assert a_method(with, many, arguments)
I get this
assert variable = a_method(with, many, arguments)
assert variable
The fact is that I don't know how to replace the entire line instead of just inserting some the snippet.
The more I think about it, the more I think you do need to "Replace Document" as the command's output.