When I press tab for autocompletion (with the supertab plugin, but its applicable with vim's autocomplete feature as well), the selection scrolls from the bottom-most selection towards top with the selection text being replaced under the cursor. Is it possible to prevent replacing the text under the cursor, maybe my preventing scrolling even if I press tab multiple times.
In the end, the behaviour would be same as how bash works.. You keep typing and pressing tab until you get the required word. No scrolling through the suggestions.

The behaviour would be similar to:

set completeopt=longest

but with a menu only for previewing the suggestions.
The one below allows it for just the first tab. Another tab starts scrolling through the menu. The behaviour I expect is to show a menu only for showing suggestions, no scrolling.

set completeopt=longest,menu,noselect

Why do I require this behaviour? Say, these are the available words:


I intend to write FooBarFoo. I type F<tab>. With set completeopt=longest,menu,noselect, it autocompletes to Foo and show the menu with the remaining suggestions. Now I type FooB<tab> and it starts scrolling and autocompletes to one of the suggestions. Here, I expect it to again complete to the longest word FooBar and show valid suggestions.


1 Answer 1


I don't use Supertab but that sounds similar to Vim's 'wildmode' setting "longest". In the Supertab docs there's a global configuration variable that seems related: g:SuperTabLongestEnhanced.

If you enable it with

:let g:SuperTabLongestEnhanced = 1

...then according to :h g:SuperTabLongestEnhanced...

supertab will provide an enhanced longest match support where typing one or more letters and hitting tab again while in a completion mode will complete the longest common match using the new text in the buffer.

The documentation continues with this example where your buffer has the following contents:


Type F<tab>. Vim's builtin longest support will complete the longest common text 'Foo' and offer 'FooBarFoo', 'FooBar', 'Foo', and 'FooBarBaz' as possible completions.

With supertab's longest match enhancement disabled, typing B<tab> while still in the completion mode will end up completing 'FooBarBaz' or 'FooBarFoo' depending your settings, instead of the next longest common match of 'FooBar'. With supertab's enhanced longest match feature enabled, the typing of B<tab> will result in the next longest text being completed.

If you use this you might also want to look at the help for the related setting g:SuperTabLongestHighlight

  • Hey! I have added more context to the question. Please do check. Thanks. Commented Jun 15, 2021 at 9:49
  • 1
    And yes, the vim behaviour would be similar to set wildmode=longest,list. Commented Jun 15, 2021 at 9:51
  • @subtleseeker Now I'm just confused. You're not talking about supertab at all? Are you talking about autocomplete in a buffer or completion from the command-line?
    – B Layer
    Commented Jun 16, 2021 at 2:14
  • @B Layer Supertab seems to use the same completeopt feature of vim. I just removed "supertab" from title to broaden the scope of the question. Its valid for both supertab as well as vim's autocomplete in general. Commented Jun 16, 2021 at 6:21
  • The configuration option I describe in my answer extends Vim's functionality in the plugin. Maybe you should make a feature request with that plugin for the functionality you seek. I don't know what the effort would be...looking at the plugin code might help. Will check it out, time permiitting.
    – B Layer
    Commented Jun 16, 2021 at 15:59

Your Answer

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

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