0

I have two keymaps like this

vim.keymap.set("n","te","<C-w>l|ia.exe<CR>")
vim.keymap.set('n', 'c', ':w <bar> !gcc "%" -o "~/Newfolder/nvimoutput/a.exe"<CR><CR>', { silent = true })

I need to combine them both into something like this

vim.keymap.set("n","cf","{how do i do this part now?}")

I tried 'bar' and '|' between them but it didnt work maybe its not using cmd mode.

2 Answers 2

0

Without Lua, a sane solution would be

:nmap cf tec

where we use nmap because we want recursive mapping interpretations (we want tec to be interpreted as mappings, if possible).

0

I would simply concatenate both:

vim.keymap.set("n","cf",'<C-w>l|ia.exe<CR>:w <bar> !gcc "%" -o "~/Newfolder/nvimoutput/a.exe"<CR><CR>')

Mappings are executed in the starting mode (here Normal) and is just a list of key strokes to be sent.

2
  • 1
    thanks that helped!
    – Prajwal
    Jan 14 at 17:24
  • Thanks for the feedback. If it solves the problem maybe you could accept the solution using the v button next to the arrow voting buttons. It allows the question to rest ans rassure others that is worth trying :-) Jan 14 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.