My IntelliJ Idea editor leaves a sort of virtual space before string arguments when functions are called (see the string "street" below):
I call it virtual because there's no character to be deleted there, but it can be seen clearly and bothers me. I'm not sure if it's a feature or a bug. I'm using the Community Edition 2016.3 on Ubuntu 16.04.
This is new feature of IDEA 2016.3 called Parameter hints. And it usually looks like:
The idea of it is that editor shows parameter hints for literals and nulls used as method arguments. These hints make code much more readable.
If you find hints redundant for a certain method, you can tell the IDEA not to show hints for this method. To disable hints completely:
uncheck Settings → Editor → General → Appearance → Show parameter name hints.
or just press Ctrl+Shift+A to open Find Action menu and type there parameter hint. Then either click Toggle parameter name hints or Appearance: Show parameter name hints menu item:
The reason why you don't see parameter names may be your UI options. Set the appearance and colors to default values.
You may have changed the code style for Java source code under File | Settings | Editor | Code Style | Java (for Windows and Linux) or IntelliJ IDEA | Preferences | Editor | Code Style | Java(for OS X).
If this is the case you have likely changed either the spacing settings for method opening braces or the spacing settings for method parameters. Just from the image I can't tell which setting is specifically causing this to happen, so could you perhaps edit in a screenshot of the your editor's current code style settings?
Related
I'm editting a .tsx-file and are reaching upon this bonkers file-formatting:
... If I enlarge the window a bit, then it makes more sense:
But I would still like to change it, so value and onClick aren't aligned all that way to the right. Ideally, it would try to align them with the opening bracket (as they do), unless the opening bracket is more than 35 characters, from the line start. Or something like that.
Now, I assume that it's the TypeScript-formatting that dictates the Code Style for a .tsx-file. But when I open the settings: Editor >> Code Style >> TypeScript then there are BAZILLIONS of settings.
Which leads me to three questions:
Does anyone know what I need to change, so object-attributes doesn't follow the opening-brackets width?
Could I find the name of what I'm looking for, in some smart way? I tried hovering over the massive space, hoping that the little yellow light-bulb could shine some light on, what I was after.
Are there any presets, to be found somewhere? So I don't need to engineer a new Code Style, if I dislike the default.
Make sure that the following option is disabled:
Settings (Preferences on macOS)
Editor | Code Style | TypeScript | Wrapping and Braces
Function call arguments: Align when multiline
NOTE: It is possible that the default value has been changed somewhere since the previous version as I have seen a few questions for the same option but different language (PHP and JavaScript).
HINT 1: Did you know that you can paste your own code in the preview area and start changing options to see how they will affect it? It helps locating the right option a lot.
HINT 2: There is a special popup that shows formatting rules applied to the code. It does not show all possible options but can give you a hint what to look for. To invoke it:
Use Help | Find Action... (or Action tab on Search Everywhere -- they use to be different popups but are using the same popup nowadays)
Type adjust to filer actions
Select and invoke "Adjust code style settings" action
It will give you a popup with applicable rules (it's a limited set: may not list all).
An example for PHP code:
I would like to exclude a specific line (or minimum sized unit) from IntelliJ's clean-up code option. We need to workaround this problem with type inference of exceptions which was fixed in Java 9 but we are stuck in Java 8.
The workaround being cleaned by IntelliJ is given by Oracle in the link:
- return g(f("Hi", MyException.class));
+ return g(this.<String, MyException>f("Hi", MyException.class));
This fix is cleaned up by intellij if you tick clean-up code.
We can push with 'clean-up code' unticked but it has many contributors so someone will eventually tick and undo the fix.
You can define formatter markers: Preferences | Editor | Code Style | Enable formatter markers.
Check Example of using formatting markers
Solved, critically in the code as we do not push changes to our individual IntelliJ configurations.
Alt + Enter on the greyed out generic (the warning)
highlight Remove all type arguments and press right arrow
Suppress for ...
For 'method' an annotation #SuppressWarnings will appear - this is my personal preference.
Does anyone know a way to search for all (and only) the commented code across all classes in a java project?
For example, using "Find in Path" to search for "//" is not what I want because it also returns URIs (http://......). I want a specialized way to do that.
Thanks in advance.
You can use Structural Search in IntelliJ IDEA.
Below screens as for the version 2019.1.1 (Ultimate Edition) (Works for IntelliJ IDEA 2020.3 too)
Go to Edit > Find > Search Structurally...
File type should be Java and select any path wherever you like to search.
From the top right corner click on gear icon and click on Existing Templates...
Then from Java > Comments, Javadoc and Metadata select comments
Then it will add /* $CommentContent$ */ to the Structural Search window as for the first screenshot.
This will find all the commented code (including Javadoc) from the selected path.
For more info refer : Structural search and replace
About the best you could do would be the Find In Path and use a REGEX of:
^//
That will fix your http:// problem. But it won't find comments that don't start at the beginning of a line. I suppose you could write a much more complex REGEX to find "//" but not proceeded by http: But of course comments can be in /* */ blocks too. So it all depends on how absolute you want to get.
As of intellij 2020.3, there is an inspection for commented out code in java:
Java | Code maturity | Commented out code
So if you want a list of commented out code, you can:
right+click your project, module, subfolder, directory or file where you want to search.
click analyze > inspect code
Click OK
This should open the inspection result window where all your commented out code will be grouped under Java | Code maturity | Commented out code :
If you don't want intellij to search for other issues too, you can create a new profile in File | Settings | Editor | Inspections exactly for that and select it in the analyze dialog.
I installed IntelliJ 2016.3.2
Build #IC-163.10154.41
Built on Dec.21, 2016
grayed var:colon is automatically added in front of argument in a caller method in Java editor as you see below ( greyed a: b: are added).
Why is this happening? I don't want to see these grayed ones.
How to set it up in config.? (I guess this is occurring in the latest version of IntelliJ since I'm using older version in another machine without this problem.)
The grey names followed by the colon are the parameter names from the method definition.
If you don't want them, right click on a grey word and select Disable Parameter Name Hints.
It's not a bug, it's a feature ;-)
If you want to reactivate it, go to Settings --> Editor --> General --> Appearance --> Option Show parameter name hints
How can i automate breaking lines (word wrap) in PHPStorm 2.1?
Automatic wrap example aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa :
This expression has automatic wrap, because I did not press return.
As I understand you want Soft Wraps, when long line is wrapped on screen into multiple lines, but still remains as single line in file.
Soft Wraps
on per file basis
View | Active Editor | Use Soft Wraps
for all files by default
Settings/Preferences | Editor | General | Use soft wraps in editor
Right margin setting
There is also
Settings/Preferences | Editor | Code Style | General --> Wrap when typing reaches right margin
But that's different (it will make actual new line).
UPDATE: In current builds IDE can use separate value for right margin per different "language" -- as long as that language has an entry in Code Style settings.
Also keep in mind that any settings from .editorconfig files (if you have such files in your project and EditorConfig plugin is installed & enabled) will override the same from Code Style settings -- it's the nature of the plugin and not a bug (it meant to work this way).
Using EditorConfig support you can configure certain settings that otherwise may not be possible to do via Code Style (e.g. settings for languages/file types that have no separate Code Style entry).
Open Settings
Type "Use Soft Wraps" in search box
In keymap tab right click on "Use Soft Wraps" and add a custom shortcut
You will be able to toggle them with that shortcut
In PhpStorm 2019.1.3 You should add file type you want to make soft wrapping on it
go to Settings -> Editor -> General -> Soft-wrap files then add any types you want
For wrapping text/code line by deafault:
File -> Settings -> Editor -> General -> section "Soft Wraps" -> checkbox "Use soft wraps in editor"
In Webstorm 2020.3 i did not found any option for all files by default, but just change the pattern:
for ALL files:
Settings > Editor > General > Soft Warps >
Soft-wrap theses files: you can change value to:
*.*
(in the other words "ANY file name" and "ANY extension file")
for SOME FILES:
*.php; *.html
(Any files with exntension .php OR .html)
simple:
cmd+F8
You can find the list of shortcut by PhpStorm in menu Help -> Default Keymap Reference!
in phpstorm 2016:
Settings/Preferences | Editor | Code Style | General --> default option-> uncheck wrap on typing
To make it automatic
After applying this point:
Use Ctrl + Alt + S to open the settings menu
Select and click Editor
Choose Code Style
Change the default value of the Hard wrap value to 90
Go back to CodeStyle and choose any of the language you work with to make specific changes
5.1 I choose HTML and Select Other and i change the value of Hard wrap at 90 and wrap on typing to Yes
5.2 I choose JavaScript and Select Wrapping and Braces and change the Hard wrap at value to 90 and wrap on typing to Yes
Continue to do it with all other languages you work with
NB: other languages may be at a default values, change it if is not preferable to you
Apply and Ok to save the changes
Using phpstorm 2019.3.4 as well as new and older version :
Use Ctrl + Alt + S to open the settings menu
Select and click Editor
Choose Code Style
Change the default value of the Hard wrap value to 90
Apply and save changes
Press Ctrl + A to highlight and select all your codes in the text editor
Press Ctrl + Alt + L to format your code nicely
Or when using the default settings for Hard wrap at 180 , follow 6 and 7