Vim Tips Wiki
No edit summary
 
(Duplicate of 493)
Line 1: Line 1:
  +
{{Duplicate|493}}
 
{{review}}
 
{{review}}
 
{{Tip
 
{{Tip

Revision as of 20:01, 1 August 2007

Duplicate tip

This tip is very similar to the following:

These tips need to be merged – see the merge guidelines.

Previous TipNext Tip

Tip: #311 - Open the folder containing the currently open file

Created: August 13, 2002 16:40 Complexity: basic Author: Thomas R. Kimpton Version: 5.7 Karma: 87/27 Imported from: Tip#311

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


Tom.

Comments

Why have it inside a gui_running block? (Does it make a difference?)

Anonymous , August 14, 2002 7:46


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>

Alan.S.Budden--AT--virgin.net , August 21, 2002 2:28