What's the best way to append the content of a string variable from a Vim script?
If variable contains no newlines, then use
call append(line('$'), [variable])
, you can also do
call append(line('$'), split(variable, "\n"))
,
execute "normal! Go".variable
, or
execute "normal! Go\<C-r>\<C-r>=variable\<CR>"
You could also put the variable into a register like this:
let @a = variable
normal! G
execute "put a"
This works with or without carriage returns.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With