TransWikia.com

How to run external commands in vim from windows OS?

Vi and Vim Asked by Bapi on August 31, 2021

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

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

Answered by run_the_race on August 31, 2021

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.

Answered by Maxim Kim on August 31, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP