PhpStorm is doing something with blank lines so that they are shown as changes in my commits - ide

Basically after changing files in PhpStorm and commiting I get a lot of these blank line changes but I haven't touched any of them.
I turned on "keep indent on empty lines" and turned off "remove trailing spaces" but it didn't fix the problem.
What's going on here? For now I have to stage lines instead of whole files to avoid pushing garbage changes but that's less than ideal.

I turned on "keep indent on empty lines" and turned off "remove trailing spaces" but it didn't fix the problem.
Settings/Preferences | Editor | General | Remove trailing spaces on: is indeed the option that controls such behaviour. As per your description you already have that disabled.
If you have .editorconfig files in your project then corresponding setting from there (trim_trailing_whitespace) will overwrite corresponding IDE settings. It is expected as it's the whole nature of such files.
In this case you have a few options here:
either edit your .editorconfig file accordingly (https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#trim_trailing_whitespace)
or disable such support in the IDE (Settings/Preferences | Editor | Code Style | Enable EditorConfig support)
or even more radical one: disable EditorConfig plugin completely (which affects the whole IDE: all projects / code styles).

Related

PhpStorm AutoComplete code is not working

I'm using PhpStorm over 3 months and it's a good IDE. I do not know what I've clicked yesterday but since yesterday I have issue with code completion in CSS mainly.
On the screen I have VS Code and PhpStorm and also I've opened the same project.
In VS Code it works perfectly. In PhpStorm it doesn't. I tried some Google First Aid like clear cache, update the IDE, turn On/Off Safe mode etc. but nothing changed.
My Code Completion settings:
Based on your PhpStorm editor area screenshot (many thanks for that BTW: not many people do post it even if asked), all your CSS files are treated as a Plain Text. It's rather unlikely to be a glitch, more like accidental settings change.
Settings/Preferences | Plugins -- make sure that CSS plugin is enabled. If not -- enable and restart the IDE.
If still the same: Settings/Preferences | Editor | File Types -- locate "Cascading style sheet" entry and make sure that it has *.css pattern there.
If not there -- it's possible that you have somehow reassigned it to "Text" file type. If it's there -- just add *.css to Cascading style sheet patterns (it will remove it from Text when doing that).
If still nothing: you would need to provide more/new screenshots.

TSLint - how to avoid that all my code underlined in red?

I loaded an angular project in ItelliJ and all the files have some code underlined in red.
The same red colour is on the scrollbar on the right.
It seems the code is full of errors, but they are just missing spaces or things like that; the project is correctly builded.
Even comments that don't have a space after the // get underlined in red.
The responsible is TSLint.
This distracts me; I would like to have underlined code only for "real" problems, and maybe yellow suggestion on the left (and not in scrollbar) for missing spaces in comments or import.
I found this (here https://github.com/Microsoft/vscode-tslint/issues/199)
tslint.alwaysShowRuleFailuresAsWarnings
but it's in visualStudio and I don't know where to add this option in intelliJ.
Do you know how to disable this red underlining?
Also another question, if I would disable TSLint, do I loose anything except formatting?
I like to have a well-formatted code, but from the IntelliJ environment I would like to have mostly the syntax errors rather than formatting, at least not in real time (maybe i can run to check the code formatting when I want, as I did until now).
Here the screenshot as requested by the first answer. The settings are ignored, maybe there is a problem in my computer... (TLSint is 5.0.0 by the way)
The editor highlights the errors according to the severity levels specified in the TSLint configuration files by default. You can either set warn as defaultSeverity ({"defaultSeverity": "warn"}) in your tslint.json or override it with a specific severity in IDE settings (Settings | Editor | Inspections | TypeScript | TSLint): uncheck Use rule severity from the configuration file to use the inspection severity for all linter rules:
if I would disable TSLint, do I loose anything except formatting
If you are mostly interested in syntax errors, you can safely disable TSLint

How do I prevent PhpStorm from moving cursor to the left when I press Ctrl+S for save file? [duplicate]

I just updated to PhpStorm 2016 and I noticed that suddenly every time I press Ctrl + S to save the file it removes the spaces/tabs that I pressed to continue writing after testing this bit of code.
Pleas help, this is very annoying for me, since I save my file after every line of code.
Here is a screenshot when I'm about to save, so after hitting Ctrl + S the text cursor will move all the way to the left, deleting all spaces & tabs.
You need to disable Settings/Preferences | Editor | General | Remove trailing spaces on: option.
(NOTE: in older IDE versions you may have just a drop down box and have to select the None option there)
P.S. Please note that if you have .editorconfig files in your project then corresponding setting from there (trim_trailing_whitespace) will overwrite such IDE setting. It is expected as it's the whole nature of such files.
If you do not like that then either edit your .editorconfig file accordingly (https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#current-universal-properties) or disable such support in the IDE (Settings/Preferences | Editor | Code Style | Enable EditorConfig support)
I recently experienced the behavior that trailing spaces got removed everywhere although the option Settings/Preferences > Editor > General > Strip trailing spaces on Save was set to Modified Lines. Setting the option to None didn't help nigher.
The reason for that was, that I had installed the JetBrains IDE plugin EditorConfig. In the root of my (PHP-) project I had a
.editorconfig file with the setting trim_trailing_whitespace = true. Setting that to false, fixed the issue.
PhpStorm 2021.2.3
Just Settings/Preferences > Editor > General
scroll down to On Save

How to stop IntelliJ IDEA from removing empty lines from .properties files?

How to stop IntelliJ IDEA from removing empty lines from .properties files?
I want to use empty lines to separate sections of files (database properties, RabbitMQ properties, business properties, etc).
When file is saved, empty lines are removed.
I have IntelliJ IDEA 2016.1.2, with 'Save actions' and 'Properties' plugins.
I see no option to controll empty lines in .properties files anywhere.
This is a bug in 2016.1 and 2016.2:
IntelliJ Bug IDEA-157903
This will be fixed in 2016.3, you can try the IntelliJ EAP
As a workaround, I defined Shift + Ctrl + s to be the Save All, so when I notice that IntelliJ delets my blank lines, I issue an undo and use the shortcut with Shift to save the file without reformating.
Update November 2016: I can confirm that a option to keep blank lines in property files was added in version 2016.3
IntelliJ does that when you run Reformat Code action.
It can be disabled by disabling "Formatting actions -> Reformat file" in the Save Actions plugin settings. However, by doing this all your files are of course not being reformatted upon save.
There is blank lines settings for java code in Settings -> Editor -> Java -> Blank lines, but unfortunately not for property files as far as I know.
Better way to prevent reformatting would be just to add property file exclusion using the following regex
.*/.*\.properties
However, there seems to be issue currently which ignores this settings in some cases
https://github.com/dubreuia/intellij-plugin-save-actions/issues/29
Edit: issue is resolved in 0.11 version of the plugin. Exclusion regex works properly.

Disable reformatting code when saving files

I made a small change to an old java file in IntelliJ and when I save the file the IDE automatically reformats all the code. Normally this would be preferable, however it seems almost every line has unnecessary white space that gets cleaned up. Now it appears the entire file was modified even though I only made a small fix. This will make looking at the significant changes in VCS more difficult.
Is there a way to disable code reformatting when a file gets saved? So far I haven't had any luck finding the setting in the Project Settings dialog. I'm using IntelliJ IDEA 9.0.2
Alternatively I could perform the reformat, commit the changes, and then make my modification but I feel that this will end up happening a lot and I don't want to impose my formatting preferences on code owned by other groups.
Settings | Editor | General > Other | Strip trailing spaces on Save -> None.
Updated for IntelliJ Idea 2021+
Settings | Editor | General > On Save | Remove trailing spaces on: <...> -> None.
For newer versions (at least WebStorm 2018), Ctrl + S is bound to a save Macro that has a reformat code action followed by save.
You can remove this reformat with Ctrl + Shift + A search for Macro then modify the save one.
Edit | Macros | Edit Macros | save | - on the Action: Reformat...
You can add these comments to make it temporarily disable formatting on the file, or a specific function:
// #formatter:off
If you want one section to remain, you can also add this:
// #formatter:on
IntelliJ Documentation Link
If #formatter:off is not working, you can enable it in preferences:
Today in 2020 IDEA is silently formatting HTML before commit, which might break your web pages appearance. To disable that unselect this checkbox:
Preferences -> Tools -> Actions on save -> uncheck "Reformat Code"
Settings > Tools > Actions on save > first line with checkbox "Reformat code"
change "Whole file" to "Changed lines"
As it advertise only the modified lines will be affected by formatting on save.