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

Nordine Lotfi
  • 683
  • 4
  • 16

1 Answers1

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.

filbranden
  • 28,785
  • 3
  • 26
  • 71