For example, if I run some external program (formatter) from vim and write result of it to some variable:
let result=system("some_program", getline(1, "$"))
" do something with result
How I can replace all current buffer content by the result
?
PS result must be same as %!some_program
, but I can not use this. If program failed it return not 0
code and error message with line and column of error, I use this message for create cbuffer
. So I need write result of program to variable, check return code and handle it.
some_program
. Why not just use%!some_program
then? Update your question to indicate why using that is not an option...