Netbeans 7.0.1 Word Wrap - netbeans

I know there are a bunch of posts about this already, stackoverflow: word wrap in netbeans, for one, and there are some people that say it is already included in netbeans 7, but for the most part they are all old, or inconclusive. I use netbeans 7.0.1 and the included word wrap is half-assed and glitchy at best. Going to Tools > Options > Editor > Formatting > Line Wrap and setting it to either "After Words" or "Anywhere" both result in practically the same sort of wrapping and neither one is very reliable. On occasions it will wrap as expected, but more often than not you can end up with anywhere from one word to an entire paragraph past the vertical scrollbar. Is there something I am missing or is that really the way that's supposed to work?
I'm still looking and will post any significant finds, but does anyone know of a way to fix this, or a plugin to install for it, or anything? I would have figured after 4 years of inquiries (2008 is the oldest post I've found about this) netbeans would have fixed it :(
BTW: Not looking for reasons why my code shouldn't be more than 80 character long, there's no helping it sometimes and that answer isn't helpful. I have also tried adding "-J-Dorg.netbeans.editor.linewrap=true" in the netbeans.conf file, but from what I gather that is for enabling the feature in older version and did nothing in mine (I removed it).

On Netbeans 7 and 8, you can use Tools/Options/Editor/Formatting/LineWrap.
It can only be globally enabled.

you can do it from:
1) Tools -> Options -> Editor -> Formatting(Tab)
2) Select Your Language in "Language Drop down"
3) Select "Wrapping" from "Category and do what ever you want
Note: this is for Windows OS

I have done it in netbeans 8.0
Goto -> Tools-> options-> Editor-> Formatting-> language(dropdown-All languages) -> Category(dropdown-Tabs and indents) -> Line wrap(After word)
Make sure you re-open the file to see the change.

In case any one is looking for this with NetBeans 8 on OSX and ends up here, it's preferences/Options/Editor/Formatting/LineWrap

you can do it from:
1) Tools -> Options -> Editor -> Formatting(Tab)
2) Select Your Language in "Language Drop down"
3) Select "Tabs and Indents" from "Category
4) Dropdown" select any of the desired option from "Line Wrap drop down"
i.e After words or Anywhere
Note: this is for Windows OS

In Netbeans 7.2 it's actually, "Wrapping" instead of "Line Wrapping" and it's "If Long" instead of "After Words", but that probably doesn't answer your question.
You posted this almost one year ago, and you still haven't found anything yet?
I don't like how they decide to wrap by way of creating actual new lines in the editor. I would prefer if it just line-wrapped but you didn't have to make a new line - like, what you have with Notepad. However, I would prefer if you had a symbol to show that you're line wrapping on the next line, like I have seen in other IDE's before.

I done in Netbeans 8.0.2 as following way :
NetBeans->preferences/Options/Editor/Formatting/LineWrap
Hope this is useful.

Related

Eclipse mark occurrences doesn't mark all occurrences

Just installed Eclipse Juno Release, Build id: 20120614-1722.
I have 'Mark Occurrences' turned on, and I can see that it does indeed mark some of the occurrences in the JS file I'm editing. However, there's a function call that it doesn't mark.
var trackView = function() {
saveData();
},
saveData = function() {
// do something
};
When I click into the saveData occurrence where it is defined (line 4), it highlights, but it doesn't highlight the occurrence on line 2 where the function is being called. When I click into the saveData occurrence on line 2, neither highlights.
Any ideas?
The bug report in Eclipse also mentions another workaround: select something in the Outline view, and then select the field in your source again.
This works mostly always for me.
If you toggle from eclipse window to another window using ATL+TAB and come back to Eclipse window it is higlighted.
This is a known bug in Eclipse Juno and is actively (as of this writing) being investigated by Eclipse developers.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=400661
https://bugs.eclipse.org/bugs/show_bug.cgi?id=398509
UPDATE 6/2: This bug has been resolved in Release 4.2.2
https://bugs.eclipse.org/bugs/show_bug.cgi?id=398509
If you uncheck the below option it will work fine
Preference > Java > Editor > Mark Ocurrences > Uncheck: Keep marks when the selection changes.
This is a bug in Eclipse - the occurrence-highlight seems to "stick" to the first thing you point to.
Two "solutions" that at least get the highlight stuck on a new item (!!):
As #Subas Raj mentioned, defocus and refocus the window - when you come back, your current position is occurrence-highlighted. Either hit AltTab twice, or use your mouse to click/focus some other window, then back.
As #Leo and #Gorky mentions, hit AltShiftO twice. This is the shortcut for toggling highlight occurrences, and when you turn it back on, your current position is occurrence-highlighted.
And finally, a third ACTUAL solution: Replace one specific jar with a patched one: https://bugs.eclipse.org/bugs/show_bug.cgi?id=398509#c60
.. or upgrade to M7 (4.3), which now are released: https://bugs.eclipse.org/bugs/show_bug.cgi?id=398509#c62
All configuration and settings for "Mark Occurrences" are proper but it seems this is Eclipse JUNO problem.
I have been observing this issue and tried to resolve many way but in Juno, highlighting occurrences is not consistent.
Sometimes it works pretty fast, sometimes it takes time to highlight, sometimes it doesn't at all.
Also observed that once we restart Eclipse, things works proper but gradually, highlighting occurrences become slow and stops also.
~Chirag
Go to Window -> Preferences -> General -> Editors -> Text Editors -> Annotations
Under both Occurrences & Write Occurrences, make sure you have the Text as Highlighted option selected.
Also, under General -> JavaScript -> Editor -> Mark Occurrences make sure all of the check boxes are checked.
I unchecked General -- Appearance Use mixed fonts and colors for labels and now it works better...
Same as I encountered, you can try to click "Toggle Mark Occurrences" twice (turn it off and turn on) or you can also try to use Alt+Shift+O twice.
And can also try the solution of #Subas Raj, is good.
For now there is only workaround (push "Alt + Shift + O" twice):
Cannot highlight all occurrences of a selected word in Eclipse

Eclipse: Automatic line wrapping to specified width

I'd like for my lines, especially within comments, to be automatically managed so they don't get too long.
I remember once I had a configuration for vim which automatically moved the word I was typing to the next line once I reached 72 characters. It wasn't smart enough to rearrange the paragraph if I edit it, but it was a start.
Is there something that can manage these for me? I have a tendency to write really long comments in my code, and it helps to make them look neat by having consistent width, but it's always a pain to do this because oftentimes editing a sentence requires editing the entire rest of the paragraph.
I have just recently discovered the Ctrl+Shift+F feature. It is amazing and superior to Ctrl+I which is what I was using up till now, but I noticed that it does not do anything to clean up my comments.
Update: The answers are correct when working with Java in Eclipse. It seems like I have to wait for the CDT to incorporate this feature.
In "Windows -> Preferences", go to "Java -> Code style -> Formatter" to customize the formatter (called when you click Ctrl+Shift+F). In the tab "comment", you can set the maximum line width for comments (it can be different then the line width for code).
Tip: in the preferences, "Java -> Editor -> Save actions", you can make Eclipse to automatically format your file when you save it, so your code is always correctly indented !
The automatic formatting of Eclipse great no question.
If your comments are reformatted depends on what comment type and how you already have inserted line breaks.
Writing for example one very long line comment starting with // will be broken down by the formatter into multiple lines.
However you later edit the formatted lines - e.g. delete parts of it the formatter will leave them as they are. Only over-long lines will be changed.
Just in difference to block comments like this: /* comment */
Those comments will always be re-formatted in case the line is too short or too long.
If you want to format your header comment, you have to check Enable header comment formatting - that was the trick for me.
Obviously, to use this, you must create new formatter profile.

Word-wrapping comments in Netbeans

/*
*
* This is a long comment. I broke it into lines, but that made it impossible to edit without screwing up the formatting. Is there a way to make Netbeans add line breaks automatically?
*
*/
Reads: This is a long comment. I broke it into lines, but that made it impossible to edit without screwing up the formatting. Is there a way to make Netbeans add line breaks automatically?
As for today, the current NetBeans (7.3) word-wraps comments with some nice available extra options when formatting. NB: Unfortunately, this is currently only available for the Java language.
You can launch the formatter with the context menu→Format, or if you did not change the standard shortcuts, Alt+Shift+F should do.
To access the corresponding configuration: Tools → Options → Editor → Formatting; Language: Java; Category: Comments
Your IDE won't format the comment for you. You will have to do it by hand. Yes, that means you have to re-format it once you add new words to it.
If you press Enter to insert a new line, NetBeans will simply extend the docblock formatting - it won't break anything. There's also a useful option in the Preferences to display a line in the right margin, so you know when to break a line. It's in:
Tools > Options > Editor > Formatting > Right Margin
Is this what you're looking for?
Go to tools->options->editor->formatting
find line wrap and choose one the wrapping style you desire,there are two options : afterword and anywhere.
and then click OK! :D
nb : I suggest you to choose afterword

Automatic indentation on Eclipse PDT when copy-pasting

This is a simple question :
Is there any automatic indentation alignment on Eclipse PDT when you do a copy-paste ?
Because it doesn't work on my installation (raw copy-paste), but maybe this is because I use tabs instead of spaces, so I want to know if it will work if I switch to spaces.
Thanks
Actually, such a function exists now for eclipse CDT. In preferences : C++ -> Editor -> Typing, "when pasting", "adjust indentation".
Perhaps it is the same for PDT ?
I don't know specifically about PDT, but normally you can indent code with Ctrl + i, and format code with Ctrl + Shift + f (under Preferences -> Java -> Code Style -> Formatter you can specify how the formatter should work).
You can even select multiple files in the navigator and select Source -> Format to format several files then.
Tony Vermeiren had a suggestion that worked for me
(from https://bugs.eclipse.org/bugs/show_bug.cgi?id=351771#c17)
open workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.php.ui.prefs
add "smartPaste=false" at the end
save & restart eclipse
A similar idea to Davids is the use of Save actions: in the Preferences selecting Java/Editor/Save actions you can define an action to format the java code files during saves. It would solve the paste format problems during the save.
If you manage codes with different coding standards, where this formatting might have problems, define multiple formats, on a per-project basis (using the Project properties window).
Ok then I guess the answer is : no, this functionnality doesn't exists yet. I've moved to PhpStorm and I'm more than happy.
TLDR: uncheck "C/C++->Editor->Typing->Adjust indentation"
Explanation:
When i copy paste the following:
And "C/C++->Editor->Typing->Adjust indentation" checked
The result is that the second line has unwanted indentation:
To fix this just uncheck "C/C++->Editor->Typing->Adjust indentation"

Eclipse: Can you put your cursor on all lines?

In IDEA you had the possibility to put your cursor on all lines.
Is this possible in Eclipse?
Eclipse 3.5 should have a column mode (which is what I think you're asking about) - use Alt+Shift+A:
http://update.eclipse.org/downloads/drops/R-3.5-200906111540/eclipse-news-part1.html#Text
I haven't tried this since I'm stuck at version 3.4.1 for the time being. There's a patch that claims to work for 3.4.0 (http://tkilla.ch/column_mode/), but it's not working for my 3.4.1 install.
If you refer to the ability to select a group of lines (like a all function), you can use the outline view
alt text http://publib.boulder.ibm.com/infocenter/radhelp/v7r5/topic/org.eclipse.jdt.doc.user/whatsNew/images/drag-and-drop-outline.png
From there, you can move/rearrange/delete all block of text.
If it is about column mode, see my answer here.
alt text http://update.eclipse.org/downloads/drops/R-3.5-200906111540/images/block-selection-mode.png