Skip to content

map another key to a map overridden by mini #1009

Closed Answered by echasnovski
beaumccartney asked this question in Q&A
Discussion options

You must be logged in to vote

Unfortunately, there is no easy answer to that.

The most robust way is to use some version of the following code (here it is for your use case):

local remap = function(mode, lhs_from, lhs_to)
  local keymap = vim.fn.maparg(lhs_from, mode, false, true)
  local rhs = keymap.callback or keymap.rhs
  if rhs == nil then error('Could not remap from ' .. lhs_from .. ' to ' .. lhs_to) end
  vim.keymap.set(mode, lhs_to, rhs, { desc = keymap.desc })
end
remap('n', 'gx', '<Leader>gx')
remap('x', 'gx', '<Leader>gx')

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@beaumccartney
Comment options

Answer selected by echasnovski
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants