Tuesday, April 28, 2015

Commenting a block of code in vi

Many times, when modifying code or debugging, I comment out blocks of code. This is tedious to do manually.

I searched around for a way to do it fast and came across this tip:

For commenting a block of text is almost the same: First, go to the first line you want to comment, press CtrlV, and select until the last line. Second, press ShiftI#Esc (then give it a second), and it will insert a # character on all selected lines. For the stripped-down version of vim shipped with debian/ubuntu by default, type : s/^/# in the second step instead.

No comments:

Post a Comment