swapcol.vim : Swap two columns
script karma |
Rating 34/18,
Downloaded by 1603 |
Comments, bugs, improvements
|
Vim wiki
|
created by |
Tian Huixiong |
|
script type |
utility |
|
description |
Swap columns, the columns are separated by blank.
Column maybe is word, or maybe not:
col1 col2 col3 col4 col5
command! -nargs=* -range -complete=command
1. Move cursor on col1, and press ]c you will see:
col2 col1 col3 col4 col5
2. Move cursor on -range and press [c, you will see:
command! -range -nargs=* -complete=command
3. Move cousor on column, means you can put cursor on any character
of the column, not limit the first character.
4. If you don't like the default map, just modify the source.
The map code is on the bottom.
5. You can swap columns on multiple lines.
Swap column 1 and column 3 on five lines.
111 222 333 444 555 333 222 111 444 555
111 222 333 444 555 333 222 111 444 555
111 222 333 444 555 ---> 333 222 111 444 555
111 222 333 444 555 333 222 111 444 555
111 222 333 444 555 333 222 111 444 555
Step 1: select multiple lines in visual mode
press V (upper case)
and then use j or k to select lines
Step 2: call Swapcols like:
:'<,'>Swapcols 1 3
(When you press : '<,'> will come out automatically.)
Setp 3: press Enter to continue, and you will get the result.
Remember: the first column number is 1, not 0. |
|
install details |
Put this file in ~/.vim/plugin on *nix
Or put it in $vim/vimfiles/plugin on Windows |
|
script versions (upload new version)
Click on the package to download.
ip used for rating: 3.15.221.67
|