Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lisp on emacs: how to comment a multi-line expression?

For example, if I want to comment this:

(defun noop ()
  nil)

Every time I try to put a semicolon before the "(defun", the defun runs away to the next line. So how is that supposed to be done?

GNU Emacs 23.1.1

Edit: by "running away" I mean when I insert a semicolon before "(defun", a newline is automatically inserted after the semicolon and "(defun" starts on a new line again.

like image 440
Ron Avatar asked Feb 06 '11 17:02

Ron


2 Answers

M-X comment-dwim or M-;, which is the default key binding for the former — might save you a few key strokes, since it not only comments, but uncomments region, if it's commented already. Anyway, check out Emacs Manual for a proper description.

like image 149
Sergei Lebedev Avatar answered Sep 21 '22 00:09

Sergei Lebedev


See the command M-x comment-region and related.

like image 37
Rainer Joswig Avatar answered Sep 18 '22 00:09

Rainer Joswig