ideavim

Mapping to comment out multiple lines with a motion in IdeaVim?


I'm trying to recreate some of https://github.com/tpope/vim-commentary function's in IdeaVim.

I've tried various mappings in my .ideavimrc, like for example:

nnoremap gcc :action CommentByLineComment<CR>

Which works fine but I cannot do 2gcc to comment out two lines or gcip to comment out a paragraph.

I've also tried to map them like this:

nnoremap 2gcc Vj:action CommentByLineComment<CR><Esc>
nnoremap 3gcc V2j:action CommentByLineComment<CR><Esc>
" etc...

And like this:

nnoremap gc2j V2j:action CommentByLineComment<CR><Esc>
nnoremap gc3c V3j:action CommentByLineComment<CR><Esc>
" etc...

But they don't work.

Any help on how this could be accomplished?


Solution

  • Ideavim update 0.52, 2019-07-23 brought support for emulation of the vim-commentary plugin.
    It can be enabled by putting this line to .ideavimrc:

    set commentary