You may try the following 3 commands:
:redir > filelist.txt | :ls | :redir END
redi[r][!] > {file}
Redirect messages to file {file}
. The messages which
are the output of commands are written to that file,
until redirection ends.
To stop the messages and commands from being echoed to the screen, put the commands in a function and call it with :silent call Function()
. An alternative is to use the verbosefile
option, this can be used in combination with :redir
. The difference with :redir
is that verbose messages are not displayed when verbosefile
is set.
See: :help redir
.