How to delete whitespaces from a PHP file automatically in NetBeans? - netbeans

The question tells everything.
I need to know how to set up my NetBeans to not save whitespaces in a PHP file. I heard this is possible, but I can't find how to do it.
Thanks!

You can remove trailing whitespaces on save. To do so, go to Tools->Options->Editor->On Save, select the language you want (or All) and there is an option called "Remove Trailing whitespaces from" with possible values: None, All lines, Modified lines
And next time you save file, it will remove trailing whitespaces.

Related

Regex to delete all empty lines whatsoever?

In Windows 10 I use a text editor (I'd like not to point out a particular one but I usually use Visual Studio Code AKA "VSCODE").
I need a way to delete all blank lines whatsoever only with regex after I matched them with this code:
^\s*$
After I match the lines themselves, how is it possible to delete the lines?
AFAIK, regex only edit lines, not deleting lines or adding lines.
I desire a way to delete all matched (empty).
Hitting "Enter" or "Delete" in the empty "replace" box doesn't delete lines:
You were close. You were missing the new line character in your regex. This worked for me:
^\s*$\n
Without the newline character, you are matching the blank line itself which you then replace with nothing but you've left the newline character so it still leaves an empty line in place.

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.

Comparing files in eclipse show same whitespaces as different

Why does the compare files in Eclipse show difference between an identical line that starts and/or stops with white spaces?
Why would anyone ever want this "feature" anyway, all lines become marked as different. Must be a bug.
I know I can use the ignore white spaces setting, but then it ignores the differens in block indentation as well and I don't want that.
Forgot to answer this one.
It was an extra carriage return on one side (PC newline, and the other had Mac/*nix), that would make it ignore the "ignore whitespace" setting for those lines.

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.

Hungry Backspace in Eclipse?

In some editors there exist plugins implementing a feature called "hungry backspace" or "hungry delete".
If this mode is active in a text editor then one hit to the backspace key will automatically delete all whitespace chars backwards from the current cursor position up to the first non-whitespace character.
For example, this feature exists for Emacs and IntelliJ IDEA.
Does anyone know if it is also available in Eclipse?
Alt-Del is probably as close as you're going to get without writing a plugin yourself. Others have asked for this feature (coming from intelliJ) but so far it doesn't exist, or it's not published.
-Adam
CTRL-backspace is pretty close too: delete previous word:
function(); (4 spaces)
+ CTRL-BACKSPACE gives:
function
Other than that, AnyEdit plugin can convert trailing spaces into tabs (but also into "", effectively removing them)
Ctrl+Shift+Left, Backspace always works for me. works in notepad, web browsers, everywhere.
Stick to the standards :)
In SciTE, and Eclipse (3.4), Ctrl+Shift+Del with the caret after the last visible character will delete these spaces. Ie. it deletes from caret to end of line.
Actually, in SciTE I don't need to do that, since I have set it up to automatically remove these trailing spaces when saving.
Note: In Preferences > General > Keys, there is a Remove Trailing Whitespace binding (without key assignment by default) which seems to apply to File.
From eclipse Windows menu/Preferences
Search for Keys and filter to "Delete Previous Word"and Bind it to the Ctrl+Backspace