0

I'm familiar with ddp to swap lines, but what if I want to swap words on the same line? I found a Reddit post that linked to this wiki page that suggests dawbP as a word swap method, but this seems long-winded for a Vim keypress series. Is there a shorter method to execute this?

For reference, here's what I'm trying to do:

One Two Three Four

-->

One Three Two Four
1

From the wiki page, I've always used the other methods that leave the spaces the way they are.

Since that time, my mappings have evolved into something like two 30-lines long functions: https://github.com/LucHermitte/lh-misc/blob/master/plugin/vim-tip-swap-word.vim

Anyway, a 5 keys sequence isn't long. Moreover you can always define a mapping to shorten the sequence. I'm using gw and gW.

1

With your cursor between One and Two (in normal mode), type deep.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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