I have looked at the following question:
How to comment out a block of Python code in Vim
But that does not seem to work for me. How do I comment code easily wit
You can use the NERD commenter plugin for vim, which has support for a whole bunch of languages (I'm sure C++ is one of them). With this installed, to comment/uncomment any line, use
. To do the same for a block of text, select text by entering the visual
mode and use the same command as above.
There are other features in this such as comment n
lines by supplying a count before the command, yank before comment with
, comment to end of line with
, and many others, which you can read about in the link. I've found this plugin to be extremely useful and is one of my 'must have' plugins.