I have the following Vim-function:
fu! Create_file_and_write_to_it(name, text)
new
execute "normal i" . a:text
execute "w! " + a:name
endfu
I call this function like so:
:call Create_file_and_write_to_it('c:\temp\foo.txt', "here is some text")
While it creates a new buffer and writes the desired text (ie: here is some text) into the buffer, it doesn’t write the buffer to a file named c:\temp\foo.txt or any other name I could see. Neither do I get an error message.
Is there a reason for this behaviour, or am I doing something wrong, and how would I go about getting the desired functionality?
Never mind… I found it.
I should have written
instead of