Netbeans 12 "diff window" does not always highlight added or removed spaces in the code - netbeans

I upgraded Netbenas 8 to Netbeans 12 and now my diff window does not always highlight added or removed spaces in the code.
It does highlight if spaces was added or removed in the middle of the line (after a non space character), and before a non space character.
But it does not highlight when the space was added or removed form the beginning of the line, or at the end of the line. Preceding and trailing spaces change does not get highlighted.
I tried restarting Betbeans - it did not help.
I checked HTML, PHP, TXT source code, all have the same problem.
Is there any config parameter to fix it, or is it a bug?

Navigate to Tools > Options > Miscellaneous > Diff
By default, the checkbox Ignore Leading and Trailing White Space is checked:
Just uncheck the checkbox, then click the OK button. Diff will then report on leading and trailing space differences.

Related

Insert "real" spaces when tab in visual studio code

When I hit tab in visual studio code, the code gets indented with what seems to be "fake" spaces. If I hit tab on a new line without typing anything on the previously indented line, the spaces on the previous line seem to disappear. Is this fixable?
It sounds like the unnecssary (because there is no text on that previous line) is being trimmed automatically. To stop that disable the setting:
Editor: Trim Auto Whitespace
I think that'll result in what you want.

Eclipse: use both tabs and spaces for indentation

A project I'm working in has an indentation standard as follows:
A single tab-width is 4 space characters.
A double tab-width is a tab character displayed at 8 spaces wide.
Examples:
A singly-indented line begins with four spaces
A doubly-indented line begins with a tab character
A triply-indented line begins with a tab character followed by four spaces
A 4x indented line begins with two tab characters
...and so on
In Vim, the necessary configuration is achieved with:
:set tabstop=8 softtabstop=4 noexpandtab
How can I configure Eclipse to automatically enforce this indentation standard?
I don't believe Eclipse CDT supports this indentation style.
Eclipse is open source; you could consider contributing a patch to add support for this style.
Eclipse doesn't have that built-in, but it looks like the plug-in Vrapper (Vim) provides what you are looking for.
See Vrapper > Documentation > Configuration:
softtabstop - When using spaces for tabs, set this to the number of spaces inserted for each Tab key press and hitting
Backspace in InsertMode will delete that many spaces as if you had
deleted a tab character.
tabstop - Used by i_ctrl-t, i_ctrl-d, and :retab. Determines number of spaces to replace each tab character with when xpandtab is enabled.
expandtab/noexpandtab - Used by i_ctrl-t, i_ctrl-d, and :retab. Determines whether :retab should replace all tabs with spaces (true) or spaces with tabs (false). Also determines whether i_ctrl-t and i_ctrl-d will replace tabstop spaces with a tab.
Eclipse does support this natively.
My eclipse version:
The result (see in-image comments):
Step 1:
Step 2:
Step 3:
Step 4 (the most important step):

How to remove trailing whitespace *from selection* in Eclipse

The question is as simple as stated in the title - how to remove the whitespace in Eclipse, but only from the selected lines.
There are a lot of answers on SO how to remove trailing whitespace in Eclipse. Most of them focus on automatically removing it on save and all of them concern removing all of the trailing whitespace in the file.
I want none of these, as I am working on large JS files that are awfully formatted and very frequently committed; removing all the trailing whitespaces in the file would easily cause merge conflicts and a lot of noise from the people.
So I want to select specific parts of the files and fix them, in the way that this is possible with Source -> Format (Alt+Shift+F).
Shift-Ctrl-Right arrow will highlight whitespace to the right until next non-whitespace character (which may be newline). Press delete. If you lose the newline, simply press enter.

Can NetBeans remove trailing whitespace and change tabs to spaces on save?

I just started to use NetBeans, and am trying to work out how to:
Make it so that trailing whitespace is removed on save. I know that you can invoke it manually, but it’s annoying if you forget. Can it be done automatically on save? I want this done because it keeps the code neat, because it’s really annoying when you’re moving through code and the text cursor goes all over the place because of trailing whitespace you don’t see, and because trailing whitespace has unintended effects on HTML layouts and other stuff.
Make it so that tabs are automatically made into 4 spaces while you’re typing rather than converting on save, or, worse, only when manually invoked.
For the first question, NetBeans 7.0+ has now a built-in solution. You can find it in:
On NetBeans 7:
Tools > Options > Editor > General > When saving files > Remove Trailing Whitespace: Never / Always / For Modified Lines Only
On NetBeans 8 / 9:
Tools > Options > Editor > On Save > Remove Trailing Whitespace From: None / All Lines / Modified Lines Only
[Original] For your first question, how to set NetBeans to remove trailing whitespace, the answer is that there is no setting (at the moment) to control that. It happens automatically, but not to every line. Whitespace is only removed from the lines you edit (or from the entire file if invoked manually). See Petr Pisl's blog entry titled "Removing trailing spaces" for a more complete explaination. (Note that even though he is blogging about NetBeans' PHP features, this particular feature applies to the basic editor shared by all NetBeans supported languages.)
[Update] This feature has been made available as of version 7.0, as pointed out by others in comments and answers below.
For your second question, set the editor to automatically make tabs into spaces as you type, you can find that setting in the Editor Formatting options:
Click on the Tools menu, and choose Options
Click on Editor in the top row of icons
Click on the Formatting tab
In the Language field, ensure that All Languages is selected
In the Category field, ensure that Tabs And Indents is selected
Check the box for Expand Tabs to Spaces
For each additional language that is available in the Language field, check that either Override Global Options is not checked, or that Expand Tabs to Spaces is also checked for that language.
Click OK
That will make sure that when you hit the tab key the specified number of spaces is inserted rather than a tab character. As above with whitespace removal, any existing tabs in the file are left as-is unless you invoke the manual command to change the entire file. (Moreover, even if you edit a line with tabs on it--leaving the tabs in place--the editor will not convert them to spaces. Only new instances of hitting the TAB key are controlled by this option.)
Tools > Options > Editor > On Save > Remove Trailing Whitespace From: None / All Lines / Modified Lines Only
This is as of Netbeans 7.3, according to Webmut.
For netbeans 7.4+
Windows - Tools > Options > Editor > On Save > Remove Trailing Whitespace From: None / All Lines / Modified Lines Only
Mac - Netbeans > preferences > Options > Editor > On Save > Remove Trailing Whitespace From: None / All Lines / Modified Lines Only
Also you can set this as language specific.
You can also set reformat while saving.
if you want to remove all trailing spaces in the file manually ONLY ONCE, you can invoke action 'Remove Trailing Spaces' from Source menu manually.
Source -> Remove Trailing Spaces

Is there a way to get Eclipse to treat 4 spaces exactly as it treats a tab?

I understand how to get Eclipse to insert spaces in place of tabs, but then I'd rather not have to arrow through 12 spaces to reach an indented block.
Bonus points if there's a way to hide the spaces from the 'show whitespace characters'. I like to see whitespace characters for tabs and carriage returns, but the display gets too cluttered when spaces are also displayed.
Try CTRL+[right,left] arrow key. Certainly one of my most-used combos.
As it turns out, this appears to not be possible in Eclipse.
With the next Eclipse 20199.12/4.14, that might actually be possible! (albeit ten years later)
See "Backspace/delete can treat spaces as tabs"
If you use the Insert spaces for tabs option, now you can also change the backspace and delete keys behavior to remove multiple spaces at once, as if they were a tab.
The new setting is called Remove multiple spaces on backspace/delete and is found on the General > Editors > Text Editors preference page.