I should know this command earlier. It’s so convenient.
I always run M-x comment-region and M-x uncomment-region manually except when using C Mode since I can use C-c C-c when commenting.
Don’t do it that way any more. And even fortunately, M-x comment-dwim is bound to M-; by default.
According to help, this command runs different commenting command on different situation. For example, if you mark a region, this command comments code in the region. If you mark comments, this command uncomments them. Read more on help, and read now.