It's quite often that I accidentally hit Ctrl-P when I want to hit Ctrl-[ for esc from insert mode on my Macbook Pro which has no physical esc key. Then vim's keyword autocomplete menu will popup and insert some gibberish in my file. It's simply annoying. How do I disable vim's built-in keyword autocompletion? Thanks a lot.
Asked
Active
Viewed 2,111 times
1 Answers
4
To disable ctrl-p
in insert mode, the following line can be added to your .vimrc
, which maps ctrl-p
to a no-op with inoremap
. More details on that command are available with :help inoremap
(or on a prior Stack Overflow question).
inoremap <c-p> <nop>
If you'd prefer to remap ctrl-p
to ctrl-[
—as you've specified that as your intended keypress—the following can alternatively be added to your .vimrc
.
inoremap <c-p> <c-[>
In either case, you'll still be able to access Vim's completion functionality with ctrl-n
, although this works differently than ctrl-p
, as it searches for the next match as opposed to the previous match.

dannyadam
- 3,950
- 2
- 22
- 19
-
Thanks for the solution, @dannyadam. It looks like there's no option to set to turn off the keyword autocompletion itself. For now, I will disable `ctrl-p` and `ctrl-n` in insert mode. – AlvaPan Aug 07 '20 at 00:16
-
2@AlvaPan, I had mentioned `ctrl-n` in case you were still interested in accessing completion functionality with `ctrl-p` disabled. If you want to completely disable completion, a possibility is to `:set complete=` to disable all completion methods, thus making both `ctrl-p` and `ctrl-n` ineffective. – dannyadam Aug 07 '20 at 02:20