Reputation: 535
I'm trying to comment out a large piece of code in a program but it's too difficult to do it manually. Is there a program to do it for me? (making such program doesn't seem hard anyway) Also, I'm using emacs. Does emacs have such a function? (or an emacs Lisp file at least?)
Upvotes: 42
Views: 43851
Reputation: 9552
Taking up two comments of the accepted answer, this is just another key binding on top of it:
For newcomers: hold Alt
pressed and then press ;
, this can comment and uncomment the selected region.
And also for newcomers: "it's worth reading the tutorial that comes with emacs for e.g. the description of the keyboard notation and basic commands."
Upvotes: 1
Reputation: 4210
The comment-region
method bound to key M-;
. You can select region using marker and then use M-;
to comment/uncomment.
Upvotes: 36
Reputation: 30699
I bind comment-region
to C-M-;
. And remember that C-u
uncomments the commented region.
E.g. C-u 2 C-M-;
comments the region with ;;
(in Lisp). Then C-u C-M-;
uncomments the region. (The region must be active in both cases.)
Upvotes: 0
Reputation: 168101
You can mark at the beginning of the region that you want to comment out, move to the end of the region, then do C-c C-c or M-x comment-region.
Upvotes: 0