-- commenting single line
keymap("n", "<C-/>", "gcc", opts)

This is the line in my lua config for keybinds. I am using this plugin for commenting keybinds:

            "numToStr/Comment.nvim",                                -- keybinds for commenting
            config = function()

This plugin maps gcc ie. pressing g and then c and then c key combination to allow commenting and uncommenting. I wanna remap this to <C-/> so what changes do I make in my keybinds config lua?

To summarize: My plugin maps gcc to allow me to comment and uncomment and I wanna map <C-/> key combination to gcc so that it does the same job.

  • Normally to map to an already existing mapping, you would use the "recursive" variant (like :nmap \ gcc or something). Sometimes it's easier to map to the underlying implementation, especially when <Plug> mappings are used.
    – D. Ben Knoble
    Jul 19, 2022 at 14:04
  • However, it's a little unclear to me what exactly you are asking. Can you please edit to clarify what is mapped by the plugin and what you desire?
    – D. Ben Knoble
    Jul 19, 2022 at 14:04
  • 1
    @D.BenKnoble I have made some changes to try and explain my problem better, lemme know if you need any more clarifications. Jul 19, 2022 at 14:57
  • Possible duplicate of vi.stackexchange.com/q/22589/18609
    – filbranden
    Jul 20, 2022 at 1:10

1 Answer 1


As suggested here, try nmap instead of noremap.

If you're using vim.keymap.set(), remap option (inverse of noremap) is set to false by default. You can set it to true as follows:

vim.keymap.set("n", "<C-/>", "gcc", { remap = true })

See :help vim.keymap.set() for more.

Alternatively you can check :map gcc to see what it is bound to and use that for binding it your desired keys.

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.