emacs equivalent to vim's word completion with ctrl P
You can use the hippie-expand
command for completion. To bind it to Alt + /, use
(global-set-key "\M-/" 'hippie-expand)
In addition to hippie-expand
, mentioned by @choroba, here are two other standard Emacs word-completion methods:
M-/
orC-M-/
-- Dynamic abbrev expansion (akadabbrev
). See the Emacs manual, nodeDynamic Abbrev Expansion
.M-RET
orC-RET
indynamic-completion-mode
-- Standard Emacs librarycompletion.el
.
Library completion.el
is old and apparently little known, but it works great. You can complete not only to words in the same buffer but to words (program symbols etc.) that you have used in the past, including past Emacs sessions.
Your most frequently used completions are prioritized. What you do when dynamic-completion-mode
is on is recorded in a "database" on disk: the words you type or traverse, etc. To make good use of library completion.el
, read the Commentary
in the file. There is no other doc for it, but the Commentary
is pretty clear (if not totally up-to-date).
Library Icicles enhances the use of both of the above word-completion methods, dabbrev
and complete
. When there are multiple possible completions it lets you choose one using better matching possibilities (e.g. substring, regexp, not just prefix).