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 i
Just to sum up the information from other answers. For me (there might be a difference due to the fact that I'm using neovim) <C-/>
works fine on Windows, but I need to use <C-_>
on Linux:
if has('win32')
nmap <C-/> <leader>c<Space>
vmap <C-/> <leader>c<Space>
else
nmap <C-_> <leader>c<Space>
vmap <C-_> <leader>c<Space>
endif
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 /
.
If you're using iTerm2 + vim, maybe the following steps can help you:
Add following code to your .vimrc
file.
map ,cc <plug>NERDCommenterToggle
or if you have defined your <leader> as ,
map <leader>cc <plug>NERDCommenterToggle
Check if you can use ,cc
to toggle comments in vim
Open iTerm2 -> Preferences -> Keys
, click the +
button
Select Send Text with "vim" Special Chars
, enter ,cc
, like this.
Now you can use C-/
to toggle comments in vim.
Here is how you can do it regaining the selection if you are in visual mode:
nmap <C-_> <Plug>NERDCommenterToggle
vmap <C-_> <Plug>NERDCommenterToggle<CR>gv