Move entire line up and down in Vim

Posted by guy.incognito on Stack Overflow See other posts from Stack Overflow or by guy.incognito
Published on 2009-04-12T14:02:53Z Indexed on 2010/03/13 20:15 UTC
Read the original article Hit count: 297

Filed under:
|

In Notepad++, I can use ctrl + shift + up/down to move the current line up and down. Is there a similar command to this in Vim? I have looked through endless guides, but have found nothing.

If there isn't, how could I bind the action to that key combination?

Edit: Mykola's answer works for all lines, apart from those at the beginning and end of the buffer. Moving the first line up or the bottom line down deletes the line, and when moving the bottom line up it jumps two spaces initially, like a pawn! Can anyone offer any refinements?

© Stack Overflow or respective owner

Related posts about vi

Related posts about vim