With vim, I can autocomplete and get a list of any words in the buffer by hitting C-p while in insert mode.
Is there a similar command in emacs?
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-/
or C-M-/
-- Dynamic abbrev expansion (aka dabbrev
). See the Emacs manual, node Dynamic Abbrev Expansion
.
M-RET
or C-RET
in dynamic-completion-mode
-- Standard Emacs library completion.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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With