0

I want to use the echo command from vim (not the shell ones or the external command) for outputting some strings to external files.

I know I could use redir but I'm just wondering if there isn't a simpler way (in pure vimscript).

1 Answer 1

1

Using :redir > file or :redir >> file is indeed the way to redirect messages from :echo to an external file.

Another way to write to a file from Vimscript is to use the writefile() function, which takes a filename and typically a Vimscript list and writes the contents of the list to the external file, one item per line. See :help writefile() for more details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.