11

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?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Michael Durrant
  • 41,213
  • 69
  • 165
  • 232
  • Line swapping, character swapping and word swapping tips in vim can be found at [vim.wikia.com](http://vim.wikia.com/wiki/Swapping_characters,_words_and_lines). – Thor Sep 15 '12 at 14:16

2 Answers2

21

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:

How to automatically strip trailing spaces on save in Vi and Vim?

Michael Durrant
  • 41,213
  • 69
  • 165
  • 232
2

xp will swap current character with next character.

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

cuonglm
  • 150,973
  • 38
  • 327
  • 406