In vim's command-line, after typing the first few characters, when I press the tab key, the wildmenu appears. However, irritatingly, it requires me one additional press of the tab key to select the first entry.

Most of the time, it is the first entry I am looking for anyway.

How can I configure vim to automatically select the first entry whenever the wildmenu is activated?

Note: I just want to select the first entry, i.e. highlight it and ready to be activated. I still wish to retain the standard behaviour of manually activating the selection with <CR>.


1 Answer 1


You probably want to set wildmode accordingly to your needs, :h 'wildmode':

Completion mode that is used for the character specified with
'wildchar'.  It is a comma separated list of up to four parts.  Each
part specifies what to do for each consecutive use of 'wildchar'.  The
first part specifies the behavior for the first use of 'wildchar',
The second part for the second use, etc.
These are the possible values for each part:

""                Complete only the first match.

"full"            Complete the next full match.  After the last match,
                  the original string is used and then the first match

"longest"         Complete till longest common string.  If this doesn't
                  result in a longer string, use the next part.

"longest:full"    Like "longest", but also start 'wildmenu' if it is

"list"            When more than one match, list all matches.

"list:full"       When more than one match, list all matches and
                  complete first match.

"list:longest"    When more than one match, list all matches and
                  complete till longest common string.

For example, I would recommend you:

set wildmode=longest,list:full

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.