c++-comment-line below simple inserts "//" at the start of a line
c++-comment region will take the current region and run the c++comment-line on each line.
(defun c++-comment-region()
"Comment a region out"
(interactive)
(save-excursion
(save-restriction
(narrow-to-region (point) (mark))
(goto-char (point-min))
(while (> (point-max) (point))
(c++-comment-line)
(forward-line)))))
(defun c++-comment-line()
"Comment a line of C++ out"
(beginning-of-line)
(insert "//"))
3 comments:
Any reason that M-x comment-dwim (bound by default to M-;) doesn't do what you want?
Nope and thanks for the heads up.
Interesting and important information. It is really beneficial for us. Thanks
Post a Comment