skip to Main Content

Is there a way to deactivate several lines of code in visual studio?

I’m currently typing // in from of each line when I need to deactivate a segment of code (for debugging etc), but it gets tiresome.

2

Answers


  1. Chosen as BEST ANSWER

    In C/C++, use /* and */ for multi-line comment - this will make the code not run. Example:

    printf("This code will runn");
    
    /*
    printf("This code will not runn");
    printf("nor will thisn");
    */
    

    In Python you use """ for multi-line comments. Other languages might have different ones.


  2. File > Preferences > Keyboard shortcuts
    

    Search for Toggle Line Comment And edit the key combintion and choose whatever you want to perform that action

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search