Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use the NerdTree plugin for MacVim religiously, and find myself often wanting to open a folder in the Finder to work with the files. An example would be wanting to preview and copy some images.

Is there a quick way to do this that doesn't involve changing the current directory? My perfect scenario would be:

  • Move cursor to desired folder
  • Press "some key"
  • Folder opens up in the finder.
share|improve this question

Try the following

Add this map to your vimrc

nmap <Leader>b :NERDTreeFind<CR>

This you can do the following from an open file

  1. < Leader >b => highlight the file in NerdTree
  2. m => display the file options
  3. r => reveal in Finder

The above assumes you're running a GUI like MacVim for example. If you're in the shell you can add this to your vimrc

function! s:RevealInFinder()
  if filereadable(expand("%"))
    let l:command = "open -R %"
  elseif getftype(expand("%:p:h")) == "dir"
    let l:command = "open %:p:h"
    let l:command = "open ."
  execute ":silent! !" . l:command
 " For terminal Vim not to look messed up.
endfunction command! Reveal call <SID>RevealInFinder()

then when you're in the file you want to reveal in finder you do

share|improve this answer

The shell command to open a folder is

$ open /path/to/folder

In a Vim function, this command could be invoked like this:

let g:mypath = /path/to/folder
execute "silent !open " . g:mypath

NERDTree's documentation has a simple and easy to follow example that you can expand using the global objects listed above.

share|improve this answer
Pretty sure your links to the documentation are out of date. – Ben Mar 24 '14 at 19:23
@Ben, that kind of thing could happen, yes. Links fixed. – romainl Mar 24 '14 at 20:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.