Hi,

I am trying to write a list of strings to a file, I have used
writefile() successfully in the past, but this time I'm having a
problem derived from the fact that some of the items contain new line
characters.

The docs for writefile say:

> All NL characters are replaced with a NUL character.

And this seems to be the cause of my problem, since the file ends up
having ^@ where new lines should start. I don't know if the next
sentence in the docs is hinting something similar, I don't really
understand what it means:

> Inserting CR characters needs to be done before passing {list}
> to writefile().

I originally thought it meant I had to replace NL with CR before
calling writefile, but don't know exactly what the difference is
between those two.

For an example of what I am seeing, try this
:call writefile([system('ls -1 /tmp')], '/tmp/myfile.txt') and then :e
/tmp/myfile.txt
It is different than this (insert mode on an empty buffer):
<C-R>=system('ls -1 /tmp')

So my question is, is there a way to keep those new line characters in
the output file?

Thanks and regards,

-- 
Jacobo de Vera

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to