vim

How to map <C-/> to toggle comments in vim?


I use vim under iterm2. I'm using the NERDCommenter plugin, and I'd like to use Ctrl+/ to toggle comments (Trying to switch from Idea/Eclipse to vim). This is my mapping in the .vimrc :

 nmap <C-/> <leader>c<Space>
 vmap <C-/> <leader>c<Space>

But it doesn't seem to work. What can be the reason?


Solution

  • For some reason, vim registers <C-/> as <C-_> (you can see it in insert mode using <C-v><C-/>). It can be the terminal or a historical design thing that terminal apps have to suffer.

    And Gvim doesn't even try to recognize <C-/>. Sees it as single /.