Hi, All,

I have a following simple example, which illustrates my use case:

function! TestStringIf()
ruby << EOF
  def bad_string()
    return "'abc'" # can be very long string
  end
  # Is there any better way then gsub(...) ?
  VIM::command("let result_viml = '" + bad_string().gsub("'", "''") + "'")
EOF
  return result_viml
endfunction
echom "result_viml is " . TestStringIf()

In my real scenario bad_string() is ruby function which can
return arbitrary string, containing any bytes, excepting 0 (this
string is received over network from server). The length of the
string can be very big (I can imagine lengths of ~100 KB). I'm
new to both ruby and ruby's integration with VIM, therefore my
question: do I do it right way now - using gsub() to escape "'"
characters and VIM::command("let ...") to pass the string to VIML
variable?  Are there better / more efficient ways of copying
string from ruby variable to the VIML variable ?

--
Anton

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to