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?

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

2 Answers 2

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!

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.