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?
2 Answers
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.
-
-
1I guess you can if you make it your shell in vim
:set shell=powershell
Jul 15, 2020 at 18:24 -
-
install universal-ctags and use it the same way you have used it in your debian? Jul 15, 2020 at 18:31
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.