Given a string of inputs, it is possible to execute it using :normal!
: :normal! ihello
will go into insert mode and write the text 'hello'.
When mapping keys to expressions we can use a similar, albeit incompatible syntax. In Lua, we could, for example, define
vim.keymap.set('n', 's', '<c-a>y')
Given such a string, '<c-a>y'
, how would we execute it imperatively from within Lua/Vimscript without a key binding, similar to what is possible with :normal!
?