Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

2 Answers 2

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
up vote 16 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
4  
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). –  Herman Torjussen Sep 14 '12 at 19:09
1  
Just curious. What's the "windows kind"? –  Stéphane Chazelas Sep 14 '12 at 19:57
3  
    

Your Answer

 
discard

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.