nvim-comment icon indicating copy to clipboard operation
nvim-comment copied to clipboard

line_mapping and operator_mapping with the same key mapping

Open cseelus opened this issue 4 years ago • 1 comments

I tried to assign the same mapping to line_mapping and operator_mapping, like with vim-commentary, but unfortunately this doesn't work:

require('nvim_comment').setup({
    -- Should key mappings be created
    create_mappings = true,
    -- Normal mode mapping left hand side
    line_mapping = '<leader>c',
    -- Visual/Operator mapping left hand side
    operator_mapping = '<leader>c'
})

Am I missing something or is this (currently) not possible with nvim-comment out of the box?

cseelus avatar Oct 12 '21 17:10 cseelus

I encountered the same issue. A workaround:

vim.api.nvim_set_keymap('n', '<leader>c', ':CommentToggle<CR>', {noremap = true, silent = true})
vim.api.nvim_set_keymap('v', '<leader>c', ":'<,'>CommentToggle<CR>", {noremap = true, silent = true})

Markus00000 avatar Nov 05 '21 21:11 Markus00000

Closing as this is not supported, the line_mapping being a shortcut for the operator_mapping against a line.

terrortylor avatar Aug 08 '22 20:08 terrortylor