NetBeans - Replace tabs with spaces on save - netbeans-8

I need netbeans to replace tabs with spaces on file save.
I already tried: Tools -> Options -> Editor -> On Save -> Remove Trailing Whitespaces From: All Lines
and Tools -> Options -> Editor -> Formatting -> Language: All Languages -> Expand Tabs to Spaces (true)
But I was unable to find out how to automatically do this on save?
I found out that Tools -> Options -> Editor -> On Save -> Reformat: All Lines does kind of what I want, but it also reformats the code...
How does it work?

Related

Make VS code stop adding and inserting characters

VS code likes thinking for me, which is the number 1 sin a text editor can
do. To "help" it will auto type [] and {}, when deleting it will also delete [] instead of just ]. When typing HTML it also tries to auto add </div> at the wrong time...
99% of the time when it adds a character I didn't add myself it creates issues. How can I turn that feature off? i.e if I didn't explicitly press a key to modify a character, VS code has no business touching that character.
Open the Settings menu (Ctrl , on Windows or File -> Preferences -> Settings).
Select Text Editor.
You can selectively disable Auto Closing Brackets, Auto Closing Quotes, and other editor options.

Intellij: how to convert indents for all files

I know how to convert indent for a single file. I go to edit -> convert indent -> space/tab.
But I want to do this for all files under a directory.
I try click on a directory and then go to edit -> convert indent, but the options are grayed out.
You can use the shortcut Ctrl+ALT+L (Windows/Linux) or ⌥⌘+L (MAC OS X) and select the Rearrange entries option to reformat the code in the current file or reformat a module or directory.
You can also Right-click a module, file, or directory from the context menu and select Reformat Code and also select the Rearrange entries option.
This will convert the indents for all files/directories selected:
This works on most of the Jetbrains IDES (iDea, PyCharm, WebStorm, RubyMine, and so on.)
It seems there is no such dedicated option in IntelliJ, but you could just work around it using a "low-level" Replace All action.
Open the Edit → Find → Replace in Files... dialog
In case you want to convert spaces to tabs, you should
Enter in the Find field (i.e. four spaces (or whatever number of spaces the project is currently indented with))
Press the Regex search modifier (Alt + X)
Enter \t in the Replace field
NB: In case you have valid strings with 4+ spaces in them, they will get replaced too. In most use cases, however, this is not happening.
In case you want to convert tabs to spaces, you should do the same as above, but swap the Find and Replace field contents
NB: Again, if you have valid strings with tabs in them, they will get replaced too. I haven't had this use case, because I've only needed to convert in the opposite direction.
You will probably also want to set a File mask in order not to replace spaces in code-irrelevant files

How can I set Idea collapse too long string?

Look at Eclipse:
and in Idea:
So, how can I make Idea collapse multiline String like Eclipse?
Unfortunately, it seems there are no folding options for string literals.
You could try using custom folding tags, but this could will require extra comments for every string:
To check all existing folding options go to Settings > Editor > General > Code Folding.

Shortcut to apply format for XCode?

I Eclipse there is a shortcut to apply format which is:
Cmd + Shift + F
Is there a similar shortcut in Xcode which fixes the formats like tabs, etc.?
You probably want Editor -> Structure -> Re-Indent (Ctrl+i). I does not change the position of braces and things like that. For that, you'd need to use an external code formatting tool like Uncrustify.

How can I configure removing space between line comment slasles and text in Intellij IDEA?

If I want to comment line I use "Ctrl+/" and get the "//" at start of line
Then I use auto formatting with "Ctrl+alt+L" keys and get
At the end I must remove space between "//" and text manually every time...
Can I do all of these steps in one time? I didn't find any settings for this...
An alternative, not perfect though, is:
Editor -> Code Style -> Java -> Code Generation
Uncheck Line Comment at first column
The menu hierarchy is the one in Intellij IDEA 14.
I suggest you can use a setting to avoid the further indentation of your comment (the effect of the second screenshot).
Your comments will look like this:
// Bundle b = new Bundle();
That might not be quite exactly what you want, but at least you will be able to use "Ctrl+/" after the reformatting to return the line to a properly aligned state.
Here is the setting:
Go to Settings -> Project Settings -> Code Style -> Java
On the Wrapping and Braces tab, find the tree item at the top: Keep when reformatting and tick: Comment at first column
This works for Scala.
Preferences -> Editor -> Code Style -> Scala -> Other -> Comment Code
Uncheck Line comment at first column and Block comment at first column.
Example:
def regexTest(): Unit = {
Comment
When press comment shortcut in line 2, the above code becomes
def regexTest(): Unit = {
//Comment
Version 2020.2