How to map to toggle comments in vim?

后端 未结 4 1977
天涯浪人
天涯浪人 2020-12-25 10:43

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

4条回答
  •  清酒与你
    2020-12-25 11:05

    If you're using iTerm2 + vim, maybe the following steps can help you:

    1. Add following code to your .vimrc file.

      map ,cc NERDCommenterToggle

      or if you have defined your as ,

      map cc NERDCommenterToggle

    2. Check if you can use ,cc to toggle comments in vim

    3. Open iTerm2 -> Preferences -> Keys, click the + button

    4. Select Send Text with "vim" Special Chars, enter ,cc, like this.

    5. Now you can use C-/ to toggle comments in vim.

提交回复
热议问题