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.
if has("gui_running") if has("win32") " 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> endif endif
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:
!start explorer.exe %:p:h,/e<CR>:endif<CR><CR>
Notice you can simply do
to open directory containing current file in current/a new buffer