You can use the paste mode completion popup window to insert a selection of text fragments. There are two ways to implement it, see :help complete-functions and :help complete() . If the code generator returns single (and not too long) text fragments to insert, you can call the generator through system(...) , and then pass the return values ββto the completion function.
On the other hand, if the menu selection does not correspond directly to the inserted text, but is a tactical choice or actions, most plugins are a selection menu like this in a style similar to the built-in menu (for example, from :ilist ):
:echohl Title :echo 'Code fragments:' :echohl None :echo '1. foo' :echo '2. bar' :let choice = nr2str(getchar()) :if choice == 1 ...
Then paste the text matching the selection with :normal! iText :normal! iText or setline() .
As it seems to you that you want to render in visualization mode, you can first capture the selected text by starting your mapping with y .
Ingo karkat
source share