Easily comment (C++) code in vim

后端 未结 4 1968
旧时难觅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:16

    You can add this to your .vimrc file

    map  :s/^/\/\//

    Then when you need to comment a section just select all lines (Shift-V + movement) and then press CtrlC.

    To un-comment you can define in a similar way

    map  :s/^\/\///

    that removes a // at begin of line from the selected range when pressing CtrlU.

提交回复
热议问题