Tip #329: A map for swapping words
tip karma |
Rating 22/9, Viewed by 622
|
created: |
|
September 20, 2002 9:27 |
|
complexity: |
|
intermediate |
author: |
|
Chip Campbell, Arun Easi, Benji Fisher |
|
as of Vim: |
|
6.0 |
Put the following map into your <.vimrc>:
nmap <silent> gw "_yiw:s/\(\%#\w\+\)\(\W\+\)\(\w\+\)/\3\2\1/<cr><c-o><c-l>
Then when you put the cursor on or in a word, press "gw", and
the word will be swapped with the next word. The words may
even be separated by punctuation (such as "abc = def").
While we're talking swapping, here's a map for swapping characters:
nmap <silent> gc xph
This hint was formed in a collaboration between
Chip Campbell - Arun Easi - Benji Fisher
<<Vim in Microsoft Visual Foxpro |
how to stop auto indenting >>
Additional Notes
|