vim: Append a new line when adding to register

Tags: vim cli til

Using an uppercase letter when yanking to a register appends to it. If the cpoptions includes > then it will also include a newline.

This is not the default but can be useful to yank different sized selections.

It can be added with :set cpoptions+=>

Given text with variable width text on multiple lines to copy, say the first words:

target - blah
text - blah
over - blah
several - blah
lines - blah

Then with the cpoptions including > a yank can get them all with the normal command: :% norm "Ayiw

The register now includes the words separated with new lines, p

target
text
over
several
lines
Published on: 30 Apr 2023