2

Say I put a mark down somewhere with ma. Then I jump somewhere else, GG3k. I want to move what's at my mark to the current line.

I could have just dd'd it if I'd had some forethought, but is it possible to :m'a to my current location somehow? I know I could put down another mark and just :m'a'b, but is there an easier/faster way? I thought it might be . e.g. :m'a. but that didn't do it.

6

The format for :m[ove] is

:[range]m[ove] {address}

Where the range is the line or lines you want to move and the address is the target. Note that the moved line(s) will actually be placed on the line below the address.

So you're looking for a range of "mark a" and an address of "the current line". You can find all the special names for ranges and addresses here: :h :range aka :h {address}.

That tells us that marks are denoted with a ' followed by the mark name and that the current line is denoted with ..

That gives us...

:'amove .

Or, abbreviated a bit...

:'am.

By the way, you mentioned :m'a'b. That actually won't do what you suggest. When you don't specify a range the current line is implied. And when you specify two marks as the address the second one is (apparently) ignored. So that command's full form is :.move 'a and it moves the current line below the line marked as a.

2
  • Great answer, thank you. I especially appreciate the note about how what I was trying wouldn't work.
    – Harv
    Sep 7 '21 at 20:10
  • No problem. Thanks for the comment. Cheers.
    – B Layer
    Sep 7 '21 at 20:45

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.