sponsor Vim development Vim logo Vim Book Ad

upAndDown : Swapping a line with the line directly above or below

 script karma  Rating 40/15, Downloaded by 1942  Comments, bugs, improvements  Vim wiki

created by
Frederic Hardy
 
script type
utility
 
description
Swapping a line with the line directly above or below it is a common task when writing computer software.
This script provides some mappings for normal, insert and visual modes which make this more easily accomplished.
Using it allows you to move a line (or multiple lines) of text up or down within a document using the <S> and <Up>/<Down> arrow keys.
This is similar to the <Alt> and <Up>/<Down> arrow text movement feature in Eclipse.
Thanks to tips http://vim.wikia.com/wiki/VimTip191.
 
install details
Download vimball, open it with vim, and do :so %.
By default, use <S-Up> and <S-Down> to move line or block of lines.
You can override this with remapping of :
<Plug>upAndDownUp
<Plug>upAndDownDown
<Plug>upAndDownInsertUp
<Plug>upAndDownInsertDown
<Plug>upAndDownVisualUp
<Plug>upAndDownVisualDown
 

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
upAndDown.vim 0.0.3 2015-06-10 7.0 Frederic Hardy Fix a strange behavior with MacVim 7.4 related to folds.
upAndDown.vba 0.0.2 2009-03-18 6.0 Frederic Hardy Add GLVS support.
upAndDown.vba 0.0.1 2009-03-18 6.0 Frederic Hardy Initial upload
ip used for rating: 142.132.191.50

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