5

I'm wanting to learn Vim, but think it's probably too daunting. I imagine learning enough to become powerful with it, then forgetting 99% after I'm on a computerless project for a while. I know just enough right now to open a file and get stuck, or make a huge mess and exit. If there is an autocomplete feature for commands, I might be able to remember more easily.

QUESTION: Is there a version of Vim (or a plugin) that features an AutoComplete for Command Mode for those who can't remember a lot?

...and to avoid confusion, I don't mean an auto completion for a programming language functions and methods, but an autocomplete for Vim's command mode itself, with perhaps a command description too.

  • 3
    Maybe keep this up in a second monitor? Since most of the commands are one character long, I don't see auto-completion helping you very much. – Tumbler41 Feb 14 '17 at 23:46
  • 1
    Not sure this is exactly what you want, but there's this plugin: github.com/lifepillar/vim-cheat40 Once installed, you can access a cheat sheet by pressing <leader>?. You can also define your own cheat sheet, it's explained on the readme page. – user9433424 Feb 15 '17 at 1:06
  • 4
    Vim's command mode does have autocomplete (and has had it for a long time). :foo<Tab> will cycle through matching commands. You can even do :<Tab>. – muru Feb 15 '17 at 1:43
  • 1
    @user12711 If you type :echo mapleader, it should output what is your current leader key. If it gives an error (because the variable mapleader wasn't defined), then it probably means that your leader key is a a backslash (it's the default value). You can change its value in your vimrc, by writing let mapleader="your_key". For example, let mapleader = "\<Space>". See :h mapleader for more info. – user9433424 Feb 15 '17 at 14:21
  • 1
    @user12711 So if your leader key is a comma for example, then pressing <Leader>? means pressing ,?. If it's a space, then it means pressing a space then ?. And so on. – user9433424 Feb 15 '17 at 15:45
10

I really don't think that having autocompletion or not will help you learning how to use Vim. Your main problem in my opinion is to learn the basics of the editor and then learn more and more commands.

Anyway Vim has a built-in auto completion feature for the command line it is controlled with the wildmenu and wildmode options.

The first step is to create your vimrc file if it doesn't exists yet and to add the following line:

set wildmenu

See the doc :h 'wildmenu':

When 'wildmenu' is on, command-line completion operates in an enhanced
mode.  On pressing 'wildchar' (usually <Tab>) to invoke completion,
the possible matches are shown just above the command line, with the
first match highlighted (overwriting the status line, if there is
one).  Keys that show the previous/next match, such as <Tab> or
CTRL-P/CTRL-N, cause the highlight to move to the appropriate match.

Then add your wildmode configuration. Personally I used the following line but you might want to modify it to fit your needs:

set wildmode=longest,list,full

To see which options are the most relevant for you have a look at the doc :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.
When there is only a single match, it is fully completed in all cases.

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.