0

Inside a vim function I would like to have the user select a directory (instead of writing its name), I guess using :Explore, then get the filename of that directory and pass it to another function for example.

E.g. something like this

function! Test()
    let directory = ????
    call Test2(directory)
endfunction
George Kastrinis
  • 4,924
  • 4
  • 29
  • 46
  • That is not possible - there is no file selection modal dialog in Vim. You could implement it as a callback, where your directory chooser calls `Test2` on selection. However, there is no Vim functionality that lets you do that. I have never done it, but I'm thinking it might be possible in Unite.vim using `unite#custom` stuff. – Amadan Nov 11 '15 at 01:56

1 Answers1

1

This can be achieved with the browsedir() function:

function! Test()
   let initialDir = '/home/'
   let directory = browsedir('my prompt title', initialDir)
   echo "directory = ".directory
endfunction
mMontu
  • 8,983
  • 4
  • 38
  • 53
  • That seems great! But alas I guess it only works for GUI versions. It won't work in my setup (terminal) where has("browse") returns 0 – George Kastrinis Nov 11 '15 at 11:06