Looking for a way to substitute the output of an external command to a variable in vimscript.
For example, you want to execute the ls command in vimscript and substitute the result to the variable.
I executed the code below, but
redir=>message
execute":!ls"
redir END
echo message
The message variable is substituted by the ":!ls" command itself and
The ls output was not substituted.
How do I substitute the message variable for the output of ls?
Thank you for your cooperation
vim
You can use the system()
function.
let message=system('ls')
© 2024 OneMinuteCode. All rights reserved.