简体   繁体   中英

Comment multiple lines doesn't work in vim

I'm new to vim and I found that the steps online didn't work on my vim.
Usually, I do:
1, move to the cursor to the beginning of the first line
2, press shift-V (Ctrl+V will copy thing) to be Visual mode
3, select lines that needed to be commented
4, press shift-i to be insert mode and then type the comment symbols (eg //)
5, press Esc. The online tutorial said the it will comment on those selected lines automatically, but it doesn't work on my vim.
I use Linux, and I installed commentary.vim plug-in . Not sure if the plug-in is the factor. Thank you~

Between step 3 and 4, after selecting lines before you press shift-i, you need to enter "Visual Block" mode which by default key binding is Ctrl-v

This is my key map for c/c++/c# commenting in vim:

:nnoremap <C-/> I//<Space><Esc>
:vnoremap <C-/> ^<C-v>I//<Space><Esc>

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM