[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Swapping comments and code in the region
From: |
Glauber Alex Dias Prado |
Subject: |
Re: Swapping comments and code in the region |
Date: |
Sat, 23 Aug 2008 09:10:31 -0300 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux) |
weber <hugows@gmail.com> writes:
> On Aug 22, 8:44 pm, Nick Sandow <njs...@internode.on.net> 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
There is also comment-dwim , not exactly this but allows for "toggling"
of comments.
Cheers,
Glauber.