Easily comment (C++) code in vim

后端 未结 4 1985
旧时难觅i
旧时难觅i 2021-02-13 12:52

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

4条回答
  •  我寻月下人不归
    2021-02-13 13:23

    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 ci. 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 cy, comment to end of line with c$, 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.

提交回复
热议问题