Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I like the fact that I've memorized ddp for switching two lines (i.e. dd deletes the line and then p puts it back '1 higher').

Is there are similar set of keystrokes for switching 2 characters so that wsih would become wish?

share|improve this question
Line swapping, character swapping and word swapping tips in vim can be found at vim.wikia.com. – Thor Sep 15 '12 at 14:16
up vote 19 down vote accepted

The answer turned out to be xp, just not the windows kind ;)

If you are working on your vim skills generally you may also find this useful:

vi / vim - how to automatically strip trailing spaces on save?

share|improve this answer
Yes, xp transposes two characters in vi. – maxschlepzig Sep 14 '12 at 18:22
x - eat the character under the cursor (and put it in the paste buffer); p - paste the buffer after the position of the cursor (which has advanced one character in the text). – user13742 Sep 14 '12 at 19:09
Just curious. What's the "windows kind"? – Stéphane Chazelas Sep 14 '12 at 19:57

xp will swap current character with next character.

We can do another kind of swap, Xp will swap current character with previous character.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.