Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you do interactive macros or recordings in vim?

Tags:

vim

macros

I would like to define a vim macro that breaks for user input at certain times, is this possible?

EDIT: Turns out I ment recordings (q), not macros

It is possible to use the input command in a recording, but it's more trouble than it's worth.

I first mapped insert input escape to a key

:map <F2> a<C-R>=input('input: ')<CR>

then I made this recording in the q register

name: 

and pasted it into a new tab

iname: ^[

And after the final escape I pressed <C-V><F2> making the line:

iname ^[^[OQ

That I yanked back to the q buffer then used the macro, letting me use the input function. It works, but terribly.

like image 912
everett1992 Avatar asked Jul 19 '12 19:07

everett1992


1 Answers

Yes. See the function input({prompt}, [, {text} [, {completion}] ]). There is even inputdialog({prompt} [, {text} [, {cancelreturn}]]), for a dialog popup.

like image 162
fork0 Avatar answered Sep 30 '22 18:09

fork0