sponsor Vim development Vim logo Vim Book Ad

vim-swap : Reorder delimited items.

 script karma  Rating 19/7, Downloaded by 2743  Comments, bugs, improvements  Vim wiki

created by
Masaaki Nakamura
 
script type
utility
 
description
vim-swap is an plugin to reorder delimited items. Considering the following code snippet, it is easy to swap "arg2" and "arg3" but is annoying work that swaps "arg1" and "arg2" since user have to manage a word and a delimiter separately.

call foo(arg1, arg2, arg3)

This plugin serves mappings to make easier to do that kind of operations. This plugin defines three mappings in default, g<, g>, gs. g< swaps the item under the cursor with the former item. Moving cursor on the "arg2" and pressing g<, then it swaps "arg2" and the former one, "arg1", to get:

call foo(arg2, arg1, arg3)

g> swaps the item under the cursor with the latter item. Moving cursor on the "arg2" and pressing g>, then it swaps "arg2" and the latter one, "arg3", to get:

call foo(arg1, arg3, arg2)

gs works more interactive. It starts "swap mode", as if there was the sub-mode of vim editor. In the mode, use h/l to swap items, j/k to choose item, numbers 1 ~ 9 to select nth item, u/<C-r> to undo/redo, and as you know <Esc> to exit "swap mode".

Latest version: https://github.com/machakann/vim-swap
 
install details
Unzip and put all folders in your ~/.vim.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
vim-swap-1.0.6.zip 1.0.6 2017-07-05 7.4 Masaaki Nakamura Bug fixes
vim-swap-1.0.5.zip 1.0.5 2016-07-22 7.4 Masaaki Nakamura Bug fixes.
vim-swap-1.0.4.zip 1.0.4 2016-06-12 7.4 Masaaki Nakamura Bug fixes.
vim-swap-1.0.1.zip 1.0.1 2016-02-06 7.4 Masaaki Nakamura Bug fixes and performance tuning.
vim-swap-1.0.0.zip 1.0.0 2016-01-27 7.4 Masaaki Nakamura Initial upload
ip used for rating: 18.189.170.17

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github