Calling external scripts in the shell in vimscript07 Feb 2023
Some of my vimscripts need to call external commands, through the shell CLI. I learned some quirks the hard way, and documenting them here
Calling an external command is done through
system('external-command'). If you need to pass arguments you must wrap them in
shellescape(myArgument) or it will mess up spaces and quotes.
echom the result and see it through
:messages, you might see some
^@ weird characters. Those are how vim displays new lines, but not how they are encoded in the result.
To split the result on new lines, you should run
split(myResult, "\n") and not
Tags : #vim
Want to add something ? Feel free to get in touch on Twitter : @pixelastic