I learn vim in the Debian distro. In debian I can run commands like 'ls', 'cd', 'curl' etc directly from vim via power of '!' this sign. But now I am in windows because of the driver issue. But I don't able to use '!' this sign to run external commands direct form the vim. How to run external command within vim in windows os?
To run external commands from within vim on windows you should use the same vim commands you use for other OSes.
:!dir
:echo system('dir')
Just to double check, cmd.exe
that is used by default as a shell doesn't have ls
, windows doesn't have curl
and ctags
unless you install them.
If you try to run a more complex command and it fails, with Vim you need to escape the character's it uses for running commands, i.e. !
, &
, and #
. Use shellescape
with {special}
set to 1
to escape those chars with a backslash e.g.
let message = "Hello there!"
exe "!echo ".shellescape(message, 1)
See :help shellescape
!
on windows. – Maxim Kim Jul 15 '20 at 11:55