0

I have set wildmenu and set wildmode=list,full in my .vimrc.

If I go to enter a command such as buf or tabe, follow it with a space, and then hit tab, my wildmenu options take effect as I'd expect, but for some commands, such as open, I can't tab complete afterwards. Instead ^I characters are added.

Why can't I tab complete after open?

5
  • And what you expect to be completed?
    – Alex Kroll
    Aug 13, 2015 at 23:18
  • 1
    I would presume file names like when doing tabe or buf Aug 14, 2015 at 4:57
  • 5
    open has only one argument :open /pattern/ (see :help open) and no complete options. For file completion you must define your own command, something like this :command -complete=file -nargs=1 Open open <args> see :help command. You can define custom function completion. Or use :edit command instead.
    – Alex Kroll
    Aug 14, 2015 at 8:21
  • 3
    Also see: What does :open do in vim?. Aug 14, 2015 at 10:49
  • 1
    @Alex I think your comment should be an answer (especially the -complete argument in command creation is pretty nice to know about)
    – statox
    Aug 14, 2015 at 14:12

1 Answer 1

4

First of all you should understand What does :open do in vim? (thanks @Carpetsmoker for link)

open has only one argument :open /pattern/ (see :help open and link above) and no complete options.

For file names completion you should define your own command, something like this

:command -complete=file -nargs=1 Open open <args>

Pay attention to -complete= argument it may take some value listed in documentation and including file , file_in_path, buffer etc. and finally custom function.

-nargs=1 indicate that you command can take only one arument

See :help command for full explanation and examples.

Now you can type :Open and then press Tab

Or just use :edit command instead, it has completion option like as a buffer and tabe commands.

1
  • Did not realize open operated that way. Guess I'll have to get myself to start using edit (or just buffer and tabe, I suppose), or fallback to a custom command if I can't make the mental switch lol. Aug 14, 2015 at 18:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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