Search code examples
intellij-idea

How to stop intellij-idea from removing white spaces at end of text lines in my file?


I am using 2018.1.5 community edition of intellij editor to edit a plain text file.

I am not using a project. I start it, on Linux as follows:

  idea.sh  my_file.mpl

where my_file.mpl is plain text file.

And this works well, except for one big problem.

I need to have an empty space at end of some lines. i.e. after the line character on some line in the file, I insert some white. I see the space is there, by doing View->Active editor->Show White spaces. I can see the small tiny dotts, showing there are white space character at end of line.

But as soon as I save the file, these white spaces are removed from end of line.

This causes a problem for me (for other reason, when this file is read by another app).

Is there an option to tell it intellij NOT to remove white spaces after the last character on the line?


Solution

  • Go to File->Settings->Editor->General and under Other, set the drop down next to Strip trailing spaces on Save to whatever you wish. For future reference, you can press Ctrl-Shift-A and type a search term to find any menu command or setting very quickly. In this case, "trailing spaces" or "strip trailing spaces" works really well.