How to disable automatic removal of trailing spaces on save?

已回答

Hi, no matter what I unset/disable in Preferences, Idea keeps removing trailing spaces from original/unmodified lines on save (Ctrl+S or auto-save). The issue exists on 2024.1 as well as 2023.2.3

Unchecked removing trailing spaces on save:

No actions on save enabled:

Formatting of the specific file types disabled by the glob

Thanks a lot for any help.

1

Hello,

Could you please provide information from “Help | About” (click on Copy and paste data here)?

0

Hi Yaroslav,

thanks, this is the Help copy:

IntelliJ IDEA 2024.1 (Community Edition)
Build #IC-241.14494.240, built on March 28, 2024
Runtime version: 17.0.10+8-b1207.12 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.15.0-92-generic
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 12
Non-Bundled Plugins:
 WicketForge (6.0.10)
Kotlin: 241.14494.240-IJ
Current Desktop: MATE

 

Pavel.
 

0

Hi Antony:

4. Find the option Remove trailing spaces on and set it to None.

There is no option None. Only the checkbox can be unchecked which is already the case in my config - please see the screenshot in my post.

Thanks,

Pavel.

 

0

Pavel,

Is it reproducible with “WicketForge” plugin disabled? Do you face this issue with newly created project?

0

Is it reproducible with “WicketForge” plugin disabled?

Actually this is a C project, but disabling the WicketForge plugin makes no difference:

IntelliJ IDEA 2024.1 (Community Edition)
Build #IC-241.14494.240, built on March 28, 2024
Runtime version: 17.0.10+8-b1207.12 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.15.0-92-generic
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 12
Kotlin: 241.14494.240-IJ
Current Desktop: MATE
 

Do you face this issue with newly created project?

Now this is interesting.

I create a new empty project A. Then I copy a c file XY.c from a large project B there, create a git repo to be able to track changes (via command line). No matter how much I edit/save that XY.c file, I do not get the trailing spaces removed.

Then I go to that large git project (linux kernel) B and clean the idea project artefacts -  remove the existing .idea dir  and project.iml file, also rename the project directory to avoid any history in idea. Then I do “create project from existing sources” (B_new), wait for finishing indexing. Upon opening the same XY.c file (which I previously copied to that new project A) and doing any edit (just adding a line), idea removes all the trailing spaces at save from that file (in that large project B_new). As if there was some special setup for that project - I do not know where it could be hiding when I even changed the project path.

 

Thanks a lot for your patience.

 

Pavel.

0

Pavel,

Do you have “EditorConfig” support disabled in “Settings | Editor | Code Style”?

2

Yaroslav, thanks a lot! I did not know about the .editorconfig functionality, and its support in IntelliJ. There is indeed an official .editorconfig file in the linux kernel source, and my Idea has the EditorConfig plugin enabled and its support enabled. That .editorconfig file does define to trim trailing whitespace. Disabling the support fixed my problem right away.

Thank you for your patient help.

Regards,

 

Pavel.

0

Pavel,

You are welcome! Nice to hear that it works fine now.

0

Same problem, same solution. Thumbs up

0

请先登录再写评论。