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?

  • pls clarify why you are not able to use ! on windows.
    – Maxim Kim
    Jul 15, 2020 at 11:55
  • Could you also split your question 1. for external commands issue, 2. ctags on vim issue.
    – Maxim Kim
    Jul 15, 2020 at 11:56
  • did you get an error message? If so, which one? Jul 15, 2020 at 12:10

2 Answers 2


To run external commands from within vim on windows you should use the same vim commands you use for other OSes.

: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.

  • Power shell is the new cmd. Why I can't able to use those commands?
    – Bapi
    Jul 15, 2020 at 18:21
  • 1
    I guess you can if you make it your shell in vim :set shell=powershell
    – Maxim Kim
    Jul 15, 2020 at 18:24
  • It works. What about vim tags. How to use it?
    – Bapi
    Jul 15, 2020 at 18:29
  • install universal-ctags and use it the same way you have used it in your debian?
    – Maxim Kim
    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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.