Sequential completion (like vim's C-x C-n C-x C-n ...)

In Vim, you can use C-n to complete a word found elsewhere in the buffer (or in a different buffer). If you then hit C-x C-n it will insert the following word, and you can continue in this manner to complete a series of words one at a time.

I’ve gotten a lot of mileage out of that, and was hoping Evil/Emacs might have something similar. It does!

In Evil, instead of tapping C-x between each C-n, you tap SPC between each C-n.

For example, in a buffer like,

a█
foobar abc def ghi

tap C-n to produce,

abc█
foobar abc def ghi

then tap SPC C-n to produce,

abc def█
foobar abc def ghi

and again SPC C-n,

abc def ghi█
foobar abc def ghi

etc.

I stumbled across this while reading through the source of dabbrev-expand:

If the user inserts a space after expanding and then asks to expand again, always fetch the next word.

Vim also provides similar functionality around full line completion, i.e. C-x C-l to complete a whole line, then C-x C-l to complete the following line, etc. I don’t yet know if something similar exists in Evil/Emacs/dabbrev/etc.

1 Like

You mentioned dabbrev-expand, it already provides Vim’s “C-n” (bound to “M-/”).

The equivalent of “C-x C-l” is built-in by Doom: +company/whole-lines, or cape-line at GitHub - minad/cape: 🦸cape.el - Completion At Point Extensions

Good to know about +company/whote-lines, thanks. It doesn’t seem to provide the kind of repeatability that Vim’s does, where successive “C-x C-l” taps complete successive lines (though to be fair, that’s probably less useful than completing successive words).