Netbeans: Hide specific lines in source code - netbeans

Is it possible in Netbeans to hide some pieces of code, especially debugging code, from the Source Code View?
For example I would want to hide: System.out.println("DEBUG: ...");, with ... being whatever is needed to print some variables.
I don't like that it misses up how my code looks, but if I remove it entirely then I might need it again tomorrow for example.

In NetBeans you can hide code in editor folds. Just put the code you would like to hide in between comments of the form:
//<editor-fold defaultstate="collapsed" desc="comment">
//</editor-fold>
For example, I use this to automatically hide code with sensitive information when screen casting, giving presentations, or the like. This way the code is still functional, but I can only expose the parts that are important to the discussion.
//<editor-fold defaultstate="collapsed" desc="API-KEY">
private static final String API_KEY = "Not to be shared";
//</editor-fold>
You can also add a fold by selecting the code you wish to hide with the mouse. A light bulb icon will appear in the editor's margin. Click the light bulb and pick
Surround with //<editor-fold defaultstate="collapsed" desc="comment">...
to have the editor add the needed comments for you.

Netbeans editor allows you to hide (fold):
entire methods
inner classes
imports
Javadoc and
initial Comment and tags.
Discreet statement lines are not part of this list.
Options-->Editor-->General allows you the control of what will be collapsed.
Imagine the mess you would get into, if you have a few selected hidden statement lines and you try to find what goes wrong in a source code you can partially view.
Print statements is not the way you should use in order to test your code. Do it with the excellent Visual Debugger or with JUnit. This way you will have no more issues with mixing debugging print instructions with your actual code.

Related

Hide VSCode snippets in suggestion list when no code is written?

In VSCode there is a setting for having snippets first in the list of suggestions ("editor.snippetSuggestions": "top",). This is great, as you might want a snippet to take precedence over other intellisense items when it matches what you've written.
However, the snippets will also be ordered at the top when you display suggestions without writing anything. I often show suggestions inside classes to see what properties/methods I have available, but in those cases I have to scroll through my entire list of snippets before the properties/methods show up. Is there any way to turn off snippet suggestions when you have not written anything?
Example image of the suggestions showing above halfway down in the suggestion list:
This is not an option as of yet, and a feature request for this funtionality has been added. https://github.com/microsoft/vscode/issues/147357
In the meantime, a workaround is to hide snippets from completions and use the explicit > Insert Snippet command instead. (Copied from the issue response)

VS Code settings

I would like to change the following VS code behavior but can't find a way to do so:
When the cursor is on some items a box pops up with info about that item. I find this extremely annoying as it often blocks what I'm trying to edit. How to disable the pop up?
I code CSS on a single line, such as:
h1 {something; something; something; } And the next CSS on the next line. No Spaces!
But when I save it VS code automatically reformulates it, putting each something on a new line. This is extremely, extremely annoying! It horribly wastes space, and forces me to scroll down a lot to find something I want to edit. How do I get VS code to stop messing with My Coding Style?
To disable the pop up. Do these necessary changes Disable pop up
To stop the CSS formatting, just see in the extensions if you have downloaded CSS formatter, if so then uninstall it or disable it.

is there any eclipse plugin available for writing a memo on any line of code?

Doe anybody know of an eclipse plugin, which can be used to insert short text (in the form of memo) to remember what that line of code does or a block of code does to help me understand the existing code better and i can also refer it back later on.
Just like "Task" can be added on a line of code, although i can use "tasks" for this purpose, but that is not very convenient and intuitive.
If you want to add a short text to "remember what that line of code does or a block of code does to help me understand the existing code better", use comments. That's what they're for, and practically every formal language in the world has them.
If you want the ability to quickly jump to an arbitrary point in the code, using bookmarks is a convenient option - right click the bar immediately left of the text and choose to add a bookmark. You can then easily jump between bookmarks with the "bookmark view", which you can enable from the Window -> Show View menu.
The closest thing I can think of is bookmark support. There is native bookmark support in Eclipse and also several other vendors supply more function.
I'm assuming that there's a very good reason that you don't want to or can't modify the code.

How to highlight current method body in Eclipse?

There is a nice feature called "show selected element only" in Eclipse. When it's turned on, clicking on a method in the outline pane will show just this method only in the editor, allowing to focus on this one only, especially useful in that you don't need to worry about scrolling hard and overshooting this method when there are many nested parenthesis inside.
But sometimes I would like to have a glance of more codes around here, so have to turn this off, then back, time and time again, which is quite inconvenient. So I wonder if there is a better mechanism?
I know a built-in feature called "range indicator" (http://stackoverflow.com/questions/7049098/how-to-forbid-eclipse-to-highlight-current-method-class-in-the-margin) , but I always tend to overlook that because it's too thin.
One better solution I can imagine is using distinguished background color for currently investigated method body, and when move cursor to other methods, background highlight turn to them accordingly (works like the range indicator, but renders more obviously). In this way, both navigation flexibility and reading assistance are gained.
Is this solution possible?
Take a look at the Editbox plugin.
You might have to do a bit of tweaking to the colors to set it up. Here is a sample screenshot :
Is this what you wanted ?
Yes, with editbox and the following settings may suit your need.

Is there a way to highlight code in NetBeans manually?

When I am figuring out someone's code in NetBeans, it occurred to me I could use a feature to mark code as 'understood', or 'suspicious', etc. while going through it. Is there any way to manually highlight or format code in NetBeans, the way it is done in Word? Some plugin maybe?
The alternative, i guess, is adding short comments everywhere, which is often not too convenient.
The Netbeans Collab plugin was pretty useful to share code and color them when you are sharing it through an XMPP server or discussing the code with someone.
You could use that to talk to yourself and color parts that you want to comment on.
You could surround sections of code with an editor-fold. To quickly do this:
Select the section of code you want surrounded
Press Alt + Enter
Select Surround with // <editor-fold defaultstate="collapsed" desc="comment">... from the hints popup
Enter your tag ie. "understood"
Press enter
This will give you a collapsible section of code that when collapsed will only show the tag that you've entered for the comment attribute.