Intellij IDEA 14 - remove indentation on empty lines

I have an annoying bug regarding intellij 14.0.3 . The problem is that it contains indentation on empty lines, and I canโ€™t remove this space in any way. In the code style, I did not check the โ€œkeep padding on blank linesโ€ box and judging by how this functionality works, I would say that it does.

However, it still retains the indentation and creates bad differences in git as a space is added. This is mistake? Can I remove them in any way? I tried to uncheck this box under the language I use and the main one. None of them seem to change him.

+5
source share
2 answers

Try to enable the option "Save spaces in the run" in "Settings / Editor / General".

You can choose whether this should be done for all lines or only lines that you are changing to avoid creating unnecessary differences.

Spaces are separated when you explicitly press CTRL + S or automatically after some period (IntelliJ has autosave).

It should be noted that if you hover over an empty line and there are spaces in front of it, pressing CTRL + S will not erase spaces, because it will probably be annoying when your cursor starts to jump to the beginning of the line if the file was autosaved IntelliJ (I read somewhere on YouTrack that it was a design decision).

Here is a screenshot of the option I am describing:

enter image description here

+7
source

What I did to distinguish between spaces without opening and saving each file does not start the regular expression in the search and replace window:

  • Ctrl + Shift + R
  • Text to find
      ^ + \ n 
    Find each line starting with (^) one or more spaces (+) and nothing else (/ n).
  • Replace:
      \ n 
    New line.
  • General> Regular expression (obviously, it is important to check this box)
  • In the end, you can limit the scope as it will be a rather lengthy operation
  • Find and ultimately continue if IDEA warns of a large number of cases.
  • Click All Files to complete the actual replacement operation. This may take some time before IDEA responds.
0
source

Source: https://habr.com/ru/post/1213235/


All Articles