tpope / vim-commentary

commentary.vim: comment stuff out
http://www.vim.org/scripts/script.php?script_id=3695
5.9k stars 214 forks source link

How is it possible to customize keybindings? #98

Closed alienbogart closed 6 years ago

alienbogart commented 6 years ago

I tried using the plugs on the plugin file, no result.

I'm using NVIM v0.2.3-879-gce3bc12e2 Build type: RelWithDebInfo.

tpope commented 6 years ago

The <Plug> maps should work fine.

tpope commented 6 years ago

There was a deleted comment expressing confusion so here's an explicit example defining maps on the default gc, for future Googlers.

" Visual mode
xmap gc <Plug>Commentary
" Normal mode
nmap gc <Plug>Commentary
" Normal mode, current line
nmap gcc <Plug>CommentaryLine
" Operator pending mode (this lets you do e.g. `dgc` to delete a block of comments)
omap gc <Plug>Commentary
" Special case cgc (you can skip this one, but then `cgc` will also delete an extra blank line)
nmap cgc <Plug>ChangeCommentary