Turn off Eclipse formatter for selected code area? [duplicate] - java

This question already has answers here:
How to turn off the Eclipse code formatter for certain sections of Java code?
(13 answers)
Closed 9 years ago.
When I ctrl+shift+f up the project code, its doing its job just fine, everywhere.
But its messing the CSS, specially those filter parts and adding bunch of spaces.
Also how do I specify some portion of Java code to not be formated by that command ?

To prevent specific portions of Java code from being formatted, go to "Window > Preferences > Java > Code Style > Formatter". Click the "Edit..." button, go to the "Off/On Tags" tab and enable the tags. Afterwards, you can simply embed those tags in Java code to disable the formatting in-between them. If you don't change the default tags, something like this will do :
//#formatter:off
this.
portion.of(code
); // will not be touched by the formatter
//#formatter:on
but this will be
reformatted.
IIRC, this option only exists since Eclipse 3.6.
As for css code, if you have installed Eclipse WTP, go to "Window > Preferences > Web > CSS Files > Editor" and you will find some basic formatting options there.

You cannot configure the formatting at class level, but you can configure at the project level.
To do the configuration follow this path in eclipse
window->preferences-> java -> code style -> formatter
now select the configure project specific settings and do your changes.

Related

How to disable error highlighting in VS Code?

I need to disable error highlighting in Java files in VS Code. VS Code tries to check a Groovy file while thinking it is a Java file.
As you can see in the picture all imports after the first and the types after the first field are highlighted red (due to missing semicolons). However I do not want the error check for this Groovy file.
NOTE: I only have the plugins Clang, RedHat.Java, Markdown PDF, Sort Lines, and Uncrustify installed. Even if I disable all the red highlighting is visible.
open your preferences file and add this
"java.validate.enable": false
I didn't try it for java, but it works for typescript.
I found this:
"problems.decorations.enabled": false,
You should disable the linter, which is by default enable in VS Code.
To do so you can go to File-> Prefrences -> setting
I wouldn't think this is necessary but you might try:
"files.associations": {
".groovy": "groovy"
}
in your user settings, assuming your file extension is .groovy. If it is something else, just set it to "groovy" as well. When I create a .groovy file with your content or gibberish I get no error linting at all. What is your file extension and what does Vscode call it in the bottom right of the editor? You can click on that file type to change its file associations. See modifying Vscode file extensions.

Why is word wrap not working on eclipse?

I'm currently using eclipse Mars and I'm trying to figure out how to enable word wrap so that when my lines are too long, it can go down to the next line. I tried going to
Preferences > Java > Code Style > Formatter
and I created a new eclipse profile then set the maximum line width to 50 under the 'line wrapping' tab. I applied the feature and clicked 'Ok'. I tried to test if it worked by writing a really long line of code and it still didn't wrap. What am I doing wrong?

How to use SceneBuilder's DarkTheme in my application

Firstly, is it legal to use the dark theme of JavaFX's SceneBuilder 2 in my application? Since it is open source now here: SceneBuilder/css
Secondly, how to do this if legal? Or just for training purposes if not legal?
I tried to download the ThemeDark.css file from the link above and add it to my fxml file, but i see no change applied.
Any ideas ?
Edit (what I did):
I have downloaded the .css file and pasted it in package css.
Then I added these lines in my .fxml file (with the <> symbols but I removed them in this question as they hid the text if present) :
stylesheets
URL value="#/css/ThemeDark.css"
/stylesheets
See below resulting screenshot: (themeDark not applied)
If you are using SceneBuilder you can add a global css sheet to it and be happy with the new look.
Alternative, if you want to set it within your code you can use
scene.getStylesheets().clear();
scene.getStylesheets().add("path/stylesheet.css"); // Modify to your path
to add a style-sheet. Notice that you should put your style-sheet in a resource folder in your application, just to keep everything cleaned up.

How to disable intellij auto change my code format?

When I edit the java source code, intellij will auto format my code besides the places I edit, how to disable that ?
In the latest IntelliJ Idea (2021.3), Auto formatting can be stopped for one or more file type by going to
Preferences -> Tools -> Actions on save -> Enable or Disable Reformatting action for one or more file type
For those of you who want to disable formatting just for some specific file(s), there is a way since 2018.3 (IDEA-97848).
Go to Settings > Editor > Code Style > Formatter and add your exclusion pattern(s).
I tried disabling trim trailing spaces in code formatting but this doesn't work for my file type '.erb'.
I added my file type '.erb' to selectively disable code inspection for this file type but this doesn't work in IntelliJ version 2016.2.4.
I locked my file after I had made the changes using the lock icon in the Status Bar and this finally worked!
In Preferences > Tools > Actions on save you have a definition
BUT that can be overwritten by the following one, so check in that order:
In Preferences > Editor > Code style > [language] uncheck reformat on file save.
Update: None of those worked for me, so I change my file, commit without save (DON'T save during commit to avoid data loss, you'll be prompted) and then CTRL-Z.
Your file is committed and saved but only with your changes.
FWIW, I'm using Scala, on IntelliJ Community 2021.2, with the Scala plugin.
In my case intellij was messing with all the spaces in the code.
So, I changed following settings :
Editor > General
You can disable IntelliJ IDEA's ability to format (and therefore auto format) specific file types, but it comes at a cost.
To disable :
Settings > Editor > File Types
Select the file type you want to have never formatted
change the extension to something you don't use - for example '*.styl' to '*.oldstyl'
Now, even if you tell IntelliJ to reformat one of these files it won't.
The cost is that you lose syntax highlighting and language support all together.
In my case for stylus files it was worth it.
IDEA kept removing tab characters in sections of code that I wasn't even working in. SUPER annoying and destructive.

eclipse JSP line wrapping

In Eclipse, I've setup the Java formatter to wrap lines only when they exceed 120 characters. I would like the same setting to be used when I format JSP files, but at the moment it wraps them when they exceed 90 characters, is it possible to change this?
Window - Preferences - Web - JSP Files - Editor. Click on the link for your kind of JSP (HTML or XML content), and adjust the line width.
Note in the latest version of eclipse you won't see the line width option in jsp files editor, instead this is covered by the line with setting in html files - editor menu
Window -> Preferences -> type HTML...You'll see "Editor" so in line width, enter the value as you need. Works for me on eclipse 2018-12 version

Categories

Resources