help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Swapping comments and code in the region


From: weber
Subject: Re: Swapping comments and code in the region
Date: Fri, 22 Aug 2008 05:51:08 -0700 (PDT)
User-agent: G2/1.0

On Aug 22, 8:44 pm, Nick Sandow <address@hidden> wrote:
> Hi,
>
> I think it would be handy to have a function that made comments into
> code, and code into comments.
>
> That is, if the region consisted of the following 2 lines:
>
> foo();
> // bar();
>
> ...they would become:
>
> // foo();
> bar();
>
> Does anyone know of a package or command out there that does this?
>
> Thanks

Something like this does the trick here:

(defun comment-invert-region (beg end)
  (interactive "r")
  (goto-char beg)
  (while (< (point-at-eol) end)
        (comment-or-uncomment-region (point-at-bol) (1+ (point-at-eol)))
        (forward-line 1)))

Cheers,
HUgo


reply via email to

[Prev in Thread] Current Thread [Next in Thread]