NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

[Resolved] Multiline Comment & Uncomment Macros

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
venimus



Joined: 17 Feb 2011
Posts: 2

PostPosted: Thu Feb 17, 2011 6:56 pm    Post subject: [Resolved] Multiline Comment & Uncomment Macros Reply with quote

I know that Netbeans lacks multiline comment feature

However I made 2 macros to do the job, assign to a shortcut

Comment macro:

Code:
cut-to-clipboard "/*" paste-from-clipboard "*/" caret-backward caret-backward


Similar ones already could be found in the internet, I extended it to move the caret inside the comment block, which i think is better.

But I could not find an uncomment macro, so I made one:

Uncomment macro:

Put the carret inside a comment block and press the shortcut

Code:
"*/" selection-backward selection-backward find-selection delete-next find-previous "/*" selection-backward selection-backward find-selection find-previous find-previous delete-next find-next delete-next


However there are some drawbacks (macro commands are too limited for something more reliable):
* those macros destroy the clipboard contents
* uncomment macro works properly ONLY if the caret is inside a comment block and there is no selection, else unpredictable results may appear, use Ctrl+Z if something weird happens

So if you are careful this could save you lots of time.
Hope those are helpful.
Back to top
Tony
Posted via mailing list.





PostPosted: Fri Feb 18, 2011 8:32 am    Post subject: [Resolved] Multiline Comment & Uncomment Macros Reply with quote

Why did you bother?

The simplest way to accomplish this is to write your comment .. over however
many lines it takes, then hit 'Toggle comment'(Alt/Ctrl-C) with those lines
highlighted.

Tony

-----Original Message-----
From: venimus [mailto:address-removed]
Sent: 17 February 2011 18:57
To: address-removed
Subject: [nbusers] [Resolved] Multiline Comment & Uncomment Macros

I know that Netbeans lacks multiline comment feature

However I made 2 macros to do the job, assign to a shortcut

Comment macro:


Code:
cut-to-clipboard "/*" paste-from-clipboard "*/" caret-backward
caret-backward



Similar ones already could be found in the internet, I extended it to move
the caret inside the comment block, which i think is better.

But I could not find an uncomment macro, so I made one:

Uncomment macro:

Put the carret inside a comment block and press the shortcut


Code:
"*/" selection-backward selection-backward find-selection delete-next
find-previous "/*" selection-backward selection-backward find-selection
find-previous find-previous delete-next find-next delete-next



However there are some drawbacks (macro commands are too limited for
something more reliable):
* those macros destroy the clipboard contents
* uncomment macro works properly ONLY if the caret is inside a comment block
and there is no selection, else unpredictable results may appear, use Ctrl+Z
if something weird happens

So if you are careful this could save you lots of time.
Hope those are helpful.
Back to top
venimus



Joined: 17 Feb 2011
Posts: 2

PostPosted: Fri Feb 18, 2011 10:11 am    Post subject: Reply with quote

Because block comments have their advantages.
Please, the topic is not about line vs. block comments
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo