2

Given the following file

1
2
3
4
5

When I say :1m3

the file looks like this

2
3
1
4
5

But when I say :3m1 it looks like this

1
3
2
4
5

I thought the 3 should be before 1. Why is it like this?

  • 1
    Have you checked :h :m? – Stéphane Chazelas Mar 4 '15 at 11:05
  • @StéphaneChazelas no I have not. With this I am able to answer my own question. Thank you! – syss Mar 4 '15 at 11:09
  • 1
    Please do. Answering one's own question is recommended here. – Stéphane Chazelas Mar 4 '15 at 11:10
2

As Stéphane Chazelas pointed out by using the vim help with :h :m it states the following:

:[range]m[ove] {address}                        *:m* *:mo* *:move* *E134*
                    Move the lines given by [range] to below the line
                    given by {address}.

Therefore by moving line 1 below line 3 the result is as stated in the question. But if one wanted to move line 3 to the first line it has to be moved below line 0

1

Commands like :copy and :move put the target below the line given by {address}. You can use an address of 0 to move to the first line. Some commands (like :put) also support a reversal of before / after via :put!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.