Basically I want to select and copy a bunch of non-sequential lines (some lines only partially) from different locations of a code, in a way that each yanked line is appended to clipboard register so that I can paste them all in another file. Everything in visual mode. It is possible to append to a register like "Myy and then pasting by "pm but it is in command mode and we cannot copy a line partially.

  • What did you try?
    – romainl
    Feb 13, 2023 at 11:38
  • @romainl Well, I usually yank several lines by "V" then "y" and paste them by "p". But in this scenario the lines are not one after each other. and I have no idea how to copy them all.
    – Puya
    Feb 13, 2023 at 11:44
  • @romainl yes I can use "Myy and "mp for appending to M register. But I think it is not done in visual mode.
    – Puya
    Feb 13, 2023 at 12:20
  • Why do you think that? v"My does what you want.
    – romainl
    Feb 13, 2023 at 16:36
  • @romainlExactly! I did not know that it would be possible to use this command in visual mode. Thank you!
    – Puya
    Feb 13, 2023 at 22:13

1 Answer 1


You can use another register (e.g. a) and the append to clipboard syntax (using the A register)

To copy your first block you use it normally: "ay

To copy the following blocks you append to that clipboard: "Ay

These commands also work in visual mode: v"ay and v"Ay, respectively.

To paste it in another file you use it normally: "ap

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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