0

In the help for move:

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

and help for address:

Line numbers may be specified with:             *:range* *E14* *{address}*
        {number}        an absolute line number 
        .               the current line                          *:.*
        $               the last line in the file                 *:$*
        %               equal to 1,$ (the entire file)            *:%*
        't              position of mark t (lowercase)            *:'*
        'T              position of mark T (uppercase); when the mark is in
                        another file it cannot be used in a range
        /{pattern}[/]   the next line where {pattern} matches     *:/*
        ?{pattern}[?]   the previous line where {pattern} matches *:?* 
        \/              the next line where the previously used search
                        pattern matches
        \?              the previous line where the previously used search
                        pattern matches
        \&              the next line where the previously used substitute
                        pattern matches

Each may be followed (several times) by '+' or '-' and an optional number.
This number is added or subtracted from the preceding line number.

it seems like :m+1 should move the current line "below the line" that is +1 the current line, so if I'm on line 7, it should move the current line below line 8, i.e. current line should be moved to line 9. At least this is how I've understood manual.

Furthermore, if I'm on line 7, it seems like both :m7 and :m6 do nothing (or just moves the cursor to the start of line 7).

Is there a reason for this behaviour or "convention"?

  • With :m+1 you move the line below the following line. Then the following line moves one up, as you removed a line above it. – Ralf May 8 at 15:10
2

The behavior is correct. When you move a line down below the next line (which means two lines down) your original line is deleted afterwards, thus resulting in a new location which is only one line down from its original location.

2

I think you are correct. :m+1 does actually move the current line below the current line + 1, so if you are on line 7, :m+1 does actually move the line to below line 8.

However, after the line has been copied, the original line will be deleted (since it is a move), so it appears to be only 1 line lower. So it behaves essential the same as

:co+1
:7d

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.