Inverting two words followed by some characters
You have the following three words:
ARE HOW YOU
To invert the first two words you can use one of the following simple text ojbects solution:
Place the cursor inside the first word ARE and press the following key sequence:
Or place the cursor inside the second word HOW and press the the following key sequence:
|The cursor is
|Inside first word
|Inside second word
The result is the same.
The key sequence
daw, common to both solutions, is the text object.
you can read them as follows: Delete Around Word.
If you use the first solution you have to go to the next Word and Place the deleted word before it:
wP (note che upper P).
If you use the second solution you have to go to the Back word_ and Place_ the deleted word before it:
After both solutions you get the inversion of the first two words including the spaces:
HOW ARE YOU
Inverting two words NOT followed by some characters
You have, now, use another useful key command: the
With the cursor on the second word you can use the following sequence:
diw: Delete Inner Word
O: begin e new line abOve the cursor and press Esc
p: puts the text object in the upper (current) line
J: joins the upper line to the lower
After this solution you get the inversion of the two words with a space added:
If you need to delete che remaining space after the second word you can press
$x in Normal Mode.
Thank You for your attention.