comment or uncomment region in emacs: M-;


Vinh Nguyen


August 21, 2009

so often times in emacs u may want to comment or uncomment a region in emacs. michael zeller presents a way to create a simple macro, save it, and bind it to some keys here.

however, by default in emacs, there is a command called 'comment-or-uncomment-region' that is bound to 'M-;' . if emacs recognize a syntax or the mode of the buffer, the correct comment character will be inserted or removed. if emacs doesn't know the default, it will ask u, and u can insert it in. for example, in .conkerorrc, there is no default. i will put '//' when emacs asks me, and i can use 'M-;'. very cool!