Search code examples
vimvim-plugin

How to set shotcuts to toggle comments in vimrc file


I want to create a shortcut ctrl+c to toggle comment for .vhd files, so thing should be like this:

when I press Ctrl+c, in vim normal mode, it should add "-- " at the begining of the actual line.

I tried to add "nmap < C-c > <--space> " in my vimrc file,but it didn't work.


Solution

  • You probably want to use a plugin like vim-commentary

    That said, you can achieve what you want with the following mapping:

    nmap <C-c> I-- <esc>