Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Do You Stop Android Studio From Deleting Trailing Spaces?

My Android Studio will continuously and automatically delete trailing white spaces. Particularly if it's a blank line with nothing but white spaces. I can even add the spaces back in manually and it'll get rid of them again right in front of me within minutes.

This is causing an issue for me because I am working on a large project that has been around for a while and our diff system shows changes all over the place as a result (our diff system doesn't have an option to turn it off and we can't switch systems). This makes code review more difficult and is causing headaches as a result.

How can I prevent Android Studio from doing this? I can't find it in the settings.

Thanks

like image 953
Nullqwerty Avatar asked Dec 04 '25 12:12

Nullqwerty


1 Answers

You can disable it as follows:

  1. Go to Settings (File -> Settings)
  2. Find the Editor tab (under IDE Settings)
  3. Select NONE from the dropdown list next to Strip trailing spaces on Save. You can also set it to Modified Lines since that would also fix the problem for your specific needs.

The reason it happens automatically is because it saves changes automatically when idle. You can change this behavious as follows:

  1. Go to settings
  2. Find the General tab (also under IDE Settings)
  3. Check or uncheck the desired boxes under Synchronization
like image 196
free3dom Avatar answered Dec 07 '25 22:12

free3dom