1

I would like to disable the Alt-h key combination that brings up the horizontal terminal in Neovim.

I see the original mapping in ~/.config/nvim/lua/core/mappings.lua:

    ["<A-h>"] = {                                      
      function()                                       
        require("nvterm.terminal").toggle "horizontal" 
      end,                                             
      "Toggle horizontal term",                        
    },                                                 

This mapping is for normal mode (n).

I'm looking to add an override in .config/nvim/lua/custom/init.lua.

I've tried all sorts of approaches, using unmap, vim.api.nvim_set_keymap, map <Esc-h> <Nop>, and more, but I can't find something that works apart from commenting out the original code, which is not a good solution.

Any pointers appreciated.

Note - I have NVChad installed, if this has any impact.

4
  • 1
    Is it <Esc>-h or <Alt>-h? Commented Nov 8, 2023 at 10:24
  • 1
    @VivianDeSmedt depending on the terminal, they might be equivalent.
    – D. Ben Knoble
    Commented Nov 8, 2023 at 14:01
  • Is uninstalling nvchad an acceptable solution? I assume that’s where the original code came from?
    – D. Ben Knoble
    Commented Nov 8, 2023 at 14:02
  • vim.api.nvim_del_keymap('n', '<A-h>')?
    – rofrol
    Commented May 28 at 13:40

1 Answer 1

0

I would suggest you to add the following lines to:

~/.config/nvim/lua/custom/mapping.lua

-- more keybinds!
M.custom = {
  n = {
    ["<A-h>"] = {"<Nop>", ""}
  }
}
6
  • 1
    Perfect! Thanks. It's obvious now, and the best approach as far as I can see, consistent with the way the mapping is done in the first place. Cheers.
    – Alex D.
    Commented Nov 9, 2023 at 10:15
  • Thanks for the feedback :-). If the solution fit your need maybe you can accept the answer using the v button next to the arrow voting buttons. It allow the question to rest. Commented Nov 9, 2023 at 10:19
  • 1
    Sorry, I don’t have enough credits yet to do that.
    – Alex D.
    Commented May 30 at 7:28
  • You did :-) You don't need any credit to accept an answer to your own question :-) Commented May 30 at 7:45
  • Upvote != Accept :-/ Cheers.
    – Alex D.
    Commented Jun 10 at 7:05

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.