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).
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).
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.