18

In Bash, when there are several files with the same prefix and I type part of the prefix and hit Tab, it completes the common prefix and allows me to continue typing to differentiate among the possible results.

In Vim, when there are several files with the same prefix and I type part of the prefix and hit Tab, it completes the entire first match and lets me then select among all the matches. To reduce the set, I have to backspace until I get to the end of the common part, then type some more and hit Tab again.

I often have lots of files where there is a long common prefix, and the file I want is not among the first (for example, a directory of project files containing, among other things, various makefiles all with the name Makefile.{whatever}).

Can I make Vim complete more like Bash to save lots of key strokes?

Bonus if this can apply to other completions as well (for example, enum values that all have the same prefix)

1 Answer 1

18

You can use the wildmode option to control this.

If you use :set wildmode=list:longest, you get behaviour similar to bash.

I personally prefer to use :set wildmode=list:longest,full; this will list completions, but on the second Tab press, you can cycle between the entries (and Shift+Tab to cycle in the reverse).

This applies to all completions done by Vim.

See: :help 'wildmode'

2
  • 3
    Not insert mode completions! You need completeopt for that.
    – Rich
    Feb 9, 2015 at 16:28
  • Thanks! wildmode and completeopt are exactly what I was looking for!
    – John O'M.
    Feb 9, 2015 at 16:44

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.