Reputation: 21934
I am writing a small function that takes directory as argument .
function! GetDirectoryAndDoSomething(default)
:let directory = input('Directory: ', a:default)
"Call Some Function
endfunction
This works fairly well if I call GetDirectoryAndDoSomething('.') , however as it is a string input , there is no Tab Completion for directories . How can I actually get the tab compleition working for directory as a user input ?
Upvotes: 1
Views: 374
Reputation: 4792
You probably want -complete=dir
for your command.
command -nargs=+ -complete=dir Blah :echo "<args>"
This will echo whatever the user puts as an argument to Blah
but more importantly it will tab complete any part of the the argument to be directories.
To find out more read :h :command-completion
Upvotes: 2