0

Since dot (.) is the range indicator for the current line I was expecting

:.co

to copy the current line, but it does not do this. What am I doing wrong? In contrast

:.w my_line.txt

will write the current line to a file. Why does the range work with this command, but not copy?

2

Reading :h :co you can see:

:[range]co[py] {address}                *:co* *:copy*
            Copy the lines given by [range] to below the line
            given by {address}.

So you need to give an address (a line where you want to copy the current line). For example to put the current line on the last line of the buffer, you can use:

:.co $

If you want to get the line in a register you might want to use getline() and setreg():

:call setreg("*", getline('.'))
  • Just FYI, OP has stated that they will not accept an answer unless the person who answered upvotes the question. (Of the last 30 questions OP has asked just one has been accepted.) – B Layer Oct 13 '18 at 22:18
  • 1
    @BLayer That's good to know thank you. But even if I answered the question it was due to a simple typo so I don't think it is particularly useful for other users nor is it well researched so it won't get an upvote from me :) – statox Oct 15 '18 at 7:47
  • 1
    Absolutely. You can use that information however you see fit. I just wanted to make sure you had it. :) – B Layer Oct 15 '18 at 8:10

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.