After some tests, I found that the option "Automatically format XML edited by the visual layout editor" (in the "Settings | Android | Editors" section) may be to blame.
In my tests, I found that changing a property (e.g. layout_gravity) in graphic layout mode always wraps the file visually when I return to XML (text) mode when this option is ON, but I have no problem when it is turned off.
XML , Ctrl - Shift - F. , " "; ; Ctrl - S, , XML.
, " " " ", .
, , ; , : Ctrl - A, Ctrl - C, Ctrl - V , / . Select All, Copy, Paste; XML .