0

I have defined the following keybindings:

local opts = { noremap = true }
local ll = "<leader>i"

opts["desc"] = "Send visual lines"
vim.keymap.set("v", ll .. "l", function()
  require("toggleterm").send_lines_to_terminal("visual_lines", trim_spaces, { args = vim.v.count })
end, opts)

local newopts = opts
newopts["desc"] = "Send until cursor"
newopts["noremap"] = false
vim.keymap.set("n", ll .. "c" , "maggV`a" ..ll.."l`a", newopts)

However, the last keybinding just select until the current line and then stop.

Looks like <leader>il is not called.

Should I be able to use visual mode keybindings from normal mode keybindings that switch into visual mode?

1 Answer 1

1

The key code is actually remap and not noremap.

I would define it like this:

local opts = { remap = false }
local ll = "<leader>i"

opts["desc"] = "Send visual lines"
vim.keymap.set("v", ll .. "l", function()
  require("toggleterm").send_lines_to_terminal("visual_lines", trim_spaces, { args = vim.v.count })
end, opts)

local newopts = opts
newopts["desc"] = "Send until cursor"
newopts["remap"] = true
vim.keymap.set("n", ll .. "c" , "maggV`a" ..ll.."l`a", newopts)
9
  • 1
    I already have newopts["noremap"] = false, and I don't understand why you specify it two times Feb 15 at 14:37
  • Sorry I didn't paid enough attention :-| Feb 15 at 14:43
  • 1
    I have found the problem. It is related to the remap keyword that should be remap and not noremap. Feb 15 at 15:41
  • 1
    you are great! thanks! Feb 15 at 15:49
  • Thanks for the feedback. I'm happy we solved your problem :-) Feb 15 at 16:00

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.