Moving lines in Vim
Sometimes you might want to move line (or selected lines) into another place within current file.
There is several ways to achieve it:
Move current line up/down by lines count :m<direction><lines>
Example
:m+10 - Move current line down 10 lines
:m-5 - Move current line up 5 lines
To avoid doing math each time to calculate how much lines up/down do you need.
You could use relative numbers :set relativenumber
(and :set number
to switch back)
Another approach is to move current line into specific number: :m<line-number>
Example:
:m15 - Move current line into position of 15
Written by Vitaly
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Vim
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#