2

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>.

4

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
                  again.

"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
                  enabled.

"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
  • 1
    Wow. Cool. That indeed does work. Thank you for the answer. I have accepted it. – Krishna Apr 12 '18 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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