0
votes

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 (e.g //)
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~

1
This doesn't appear to be a programming question. Perhaps this would be better suite for Vim Stackexchange? - Brian
Before 1 you have to be in command mode. - Gilles Quenot
when you visually select those lines, what vim reports the "mode"? visual line or visual block? I mean the mode in your vim status-line. - Kent

1 Answers

1
votes

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.