Chiasmus
Chiasmus is the inversion of grammatical structure in the second of two parallel phrases, so the elements of the first appear in reverse order in the second.
The name comes from the Greek letter chi, written as a cross, because the elements meet in the middle and swap sides.
She edited to live, and lived to edit.
The two halves use the same words in reverse order, and the reversal feels like a discovery. When the terms are repeated exactly, as here, the figure is also called antimetabole; when only the grammatical shape is mirrored, chiasmus is the broader term.
Kennedy supplies the best-known modern example — ask not what your country can do for you, ask what you can do for your country — and it is worth noticing that the sentence contains no evidence at all. This is the thing to be careful about. The symmetry produces a very strong impression of having proved something, which is why chiasmus is the house style of the aphorism and of the confident-sounding falsehood. Reverse most sentences and you get nonsense that sounds wise.
In fiction it works best as a line of dialogue for a character who has rehearsed, or as the last sentence of a chapter, where the closing inversion gives a sense of a circle completed.
Use it once. Its whole force is in being the only sentence on the page shaped that way.