created August 13, 2002 · complexity basic · author Thomas R. Kimpton · version 5.7
Occasionally, on Windows, I have files open in gvim, that the folder for that file is not open. This key map opens the folder that contains the currently open file. The expand() is so that we don't try to open the folder of an anonymous buffer, we would get an explorer error dialog in that case.
" Open the folder containing the currently open file. Double <CR> at end
" is so you don't have to hit return after command. Double quotes are
" not necessary in the 'explorer.exe %:p:h' section.
:map <silent> <C-F5> :if expand("%:p:h") != ""<CR>:!start explorer.exe %:p:h<CR>:endif<CR><CR>
Why have it inside a gui_running block? (Does it make a difference?)
If you prefer to use full Explorer windows (with folder pane etc), modify as follows: