Search code examples
pythonvisual-studio-codecomments

How can I use the shortcut ctrl + # to comment multiple lines of code in Python or C++ using Vscode?


When I use Jupyter Notebook inside the browser or inside Google Colab I can comment multiple lines of code by selecting them and pressing crtl + #. This also sometimes worked in Visual Code and not only for Python but also for C++ (of course then each line began with a //). However, I have no idea what enabled this behavior and how to reproduce it, it was very convenient. If you have any idea how to enable this, I would very much appreciate your help.


Solution

  • In VS Code you can use Ctrl+/ for comment multiple lines and Alt+Shift+A for block comment .