Send Keystrokes To Neovim With nvim_feedkeys()
July 2021
This is how I'm sending keystrokes to Neovim in lua script and plugins.
local delete_key = vim.api.nvim_replace_termcodes('<BS>', true, false, true)
vim.api.nvim_feedkeys(delete_key, "i", true)Here's some examples I pulled from a repo that's no longer around (TODO: clarify these)
-- Feed some keystrokes into the current buffer, replacing termcodes.
feed_opts = feed_opts or 'n'
local to_feed = vim.api.nvim_replace_termcodes(text, true, false, true)
api.nvim_feedkeys(to_feed, feed_opts, true)
endAnd for insert:
-- Insert some text into the current buffer.
helpers.feed('i' .. text, 'x')
endend of line