I'm trying to define a macro which quickly generates a list of random-ish words.
I want the macro to turn this into a list like
a
b
c
d
e
into this
arezzo
bywords
czars
détente
eyrie
What I have so far:
- put cursor on letter
a
- start recording macro
qq
a
enter insert mode<C-x><C-k> - perform dictionary completion on the character before cursor - in this case the letter
a`<C-p>
select the last item in the completion list that appears, on my system its the wordarezzo
. (N.B. I havelongest
included in my'completeopt'
setting, which is required for<C-p>
to work in this way during completion:'set completeopt=longest,menuone,preview'
).<C-y>
accept the completion^[^[
exit insert modej
move down to the next line, ready to do the same operation on the next lineq
stop recording
when I create the macro and go through the steps manually, everything works fine, however when I execute the macro, I see a message flashing in the command line something like:
scanning dictionary file
and nothing happens, of the commands in the macro only j
is run, i.e. the cursor moves down the line, but none of the completion commands run.
Is it possible to use insert mode completions in a macro, and if so, how can I do it?
<C-p>
step... when I do that in my vim, it just gives the messageback at original
- doesn't select the last item.. I used up arrow key twice to select last word (my caseazures
), pressed enter and thenEsc+j+q
.. it then works quite fine on executing macroset completeopt=longest,menuone,preview
its thelongest
option which causes<C-p>
to immediately insert. If I removelongest
from thecompleteopt
string, I get the same behaviour as you. Also, yes the arrow keys worked ! thanks (I forgot you can use them to navigate the completion list):set completeopt=
anda<c-x><c-k><esc>j
as your macro.