For characters, it's fairly simple: xp
to swap the letter under the cursor with the following letter, and Xp
to swap the letter under the cursor with the previous letter.
The x
command deletes the character under the cursor, leaving the cursor on the next character. The X
command deletes the character just before the cursor, leaving the cursor on the same character it was on.
p
puts (pastes) the last deleted or last yanked text just after the current cursor position. (P
puts it just before the current cursor position, so xP
and XP
both leave the text the way it was before you started.)
For swapping words, I'm not sure; perhaps someone else can answer that. You can come close with dawwP
(or remap it to be shorter) but that will break on several edge cases, for example near the end of a line.