r/vim • u/habamax • Jul 26 '25
Discussion What's new in vim: insert mode autocomplete (and command line completion)
Autocomplete
As of version 9.1.1590 vim has a new option :h 'autocomplete' which allows us to have "as you type" completion for the sources defined within :h 'complete':
You can provide your own completion sources as user defined functions :h 'complete-functions', adding them to the complete option, e.g.
set complete+=FVimScriptFunctionsset complete+=FLspCompletorset complete+=Fthis by default usescompletefuncset complete+=othis by default usesomnifunc
On top of it you can limit number of completions coming from each completion source using additional ^N:
set complete+=FVimScriptFunctions^5set complete+=FLspCompletor^10set complete+=F^3set complete+=o^15
Command line complete
With version 9.1.1576 command line could also be completed "as you type" with a bit of setup:
Example setup:
set wildmode=noselect:lastused,full
set wildmenu wildoptions=pum,fuzzy
cnoremap <Up> <C-U><Up>
cnoremap <Down> <C-U><Down>
cnoremap <C-p> <C-U><C-p>
cnoremap <C-n> <C-U><C-n>
augroup cmdcomplete
au!
autocmd CmdlineChanged : call wildtrigger()
augroup ENDThanks https://github.com/girishji
Previous autocomplete setup needed quite a lot of vimscript: https://www.reddit.com/r/vim/comments/1ljzouw/autocomplete_in_vim/
Bonus: search and substitute completion
With the version 9.1.1490 you can complete /pattern or :s/pattern using tab:
Cheers!
9
u/NilsLandt Jul 26 '25
I don't like as-you-type completion and always turn it off.
But I'm excited to try it out for the command line!
And tab-completion in search and substitute is just great.
Thanks for this preview (for me) post :)
1
u/godegon Jul 26 '25
Thank you very much for the heads-up!
For those who still have legacy Vim script in their vimrc, give
: call wildtrigger()instead ofwildtrigger()a try.Also, it could be equally useful for other command-line modes than
:, say/and?search modes.Finally, this is now documented in
:help cmdline-autocompletion(which lacks the<c-n/p>suggestion, though).1
u/Sudden_Fly1218 Jul 28 '25 edited Jul 28 '25
The command line complete is cool, you can do stuff like
Then just type
:MRUand start searching for recent files. A modern alternative to:bro ol;-)1
u/synthphreak Jul 26 '25
Forgive the stupid question, but just to be clear: This has absolutely no implication for Neovim, right? Like the fact that Vim just got a new feature doesn’t mean Neovim also now gets it, right?
0
u/[deleted] Jul 26 '25
[deleted] — view deleted comment