vimrc can work with external commands in a very elegant way. You can call the commands in various means. These are the current best practices.
For simple and easy 1-5 words command, you can easily use the bang. Before the bang, please use the colon to indicate that it is a vim command. Otherwise, it is very confusing between vim commands and shell commands. Here is an example:
:!clear
For long and complicated (e.g. variable substitution) commands, you use system()
. You can capture the output and error code easily as well. If you need to print the output, you can use a simple echo. Here is an example:
let cmd = 'echo "Hello "' . vimVariable
let output = system(cmd)
echo output
NOTE:
system()
call. q
to exit the prompt and get back to editor.That's all about interacting with external commands from vimrc.