A key sequence that automatically presses keys like enter, *after* a command that requires manually typing a letter?

For instance, I want to move to the window in the top left, and move to a line using :HopVertical (which is n-mapped to j for me) with hop.nvim*, type in a character manually (I want to type it manually), then press a key like enter automatically. I tried this keymap but it doesn’t work.

  • wincmd t, j, manually typed character, <cr> (or enter pressed automatically).
  • vim.keymap.set({"n", "v"}, ";", "<cmd>wincmd t<cr>j<cr>", opts)

(I want to use this with vuffers.nvim in the top left corner, as well as other key sequences).

* show one letter hint on each line, press the hint

I think what you would want to do is:

vim.keymap.set({"n", "v"}, ";", "<cmd>wincmd t<cr><bar><cmd>HopVertical<cr>, {})

See :h map-bar for chaining commands in a mapping. And I’d recommend using the full command name HopVertical for the second part instead of relying on the j mapping which you might want to change later.