Comment/uncomment line(s) is easy in Emacs

  |   Source

It's easy if you use evil-nerd-commenter. As its README said, comment/uncomment line is only pressing ",ci" in evil-mode.

You can also select the region and press "M-;" to comment the lines in the region. If part of the line is not in the region, the whole line will still be commented out. This saves your extra key pressing for moving cursor to the beginning of the first line or moving the cursor to the end of the last line.

The reason to make commenting so efficient is that I need comment/uncomment code for debug purpose.

Some people say comment out the code is not a right way to debug. The right way is using debugger.

But if you debug some huge project, using the debugger makes no sense for many reasons:

  • debugging DSL the middleware whose debugger simply does not exist
  • The bug can be reproduced on production server
  • Too much overhead to set up debugger. Say I'm debugging component from other teams and developers and the technologies they use make configuring debugger very harder.
Comments powered by Disqus