How do I open the windows command prompt to the current directory of the active file in VIM?

cmd, command-prompt, vim, windows

Solution

I figured out a good way to do it.

:!start cmd /k cd %:p:h

This will open the command prompt to the directory of the current file.

I ended up adding these command to my vimrc file so I can easily open command prompt or windows explorer at the current file's directory.

"Open command prompt by running :Cp
command Cp :!start cmd /k cd %:p:h<CR>

"Open windows explorer by running :We
command We :!start Explorer /select,%:p<CR>

Problem

So I have a file open in vim and I would like to open the command prompt to the file's current directory. Here's what I've tried... ``` :!start cmd /k ``` This will just open the command prompt to the C:\ directory even though I've set :cd to a different directory in vim. ``` :!start cmd /k "cd c:\%" ``` This fails because the % gets escaped. ``` :!start cmd /k "set vimcwd=%; cd C:\\%vimcwd\%" ``` I'm not sure why this wouldn't work, but regardless, it's more than I'd like to type. There's got to be an easier way to do this.

Original source