I would like to populate a register with the text inside quotes for a range of lines. The register should contain all yanked text separated with new line characters. Example lines:
The "black" cat
A "tall" tree
A long "tail"
Intuitively I tried to clear my q
register with qqq
, select the lines in visual mode and run:
:'<,'>norm "Qyi"
But then all the text is on the same line which is not what I want. I would not want to use regular expressions because it is very easy to build a normal mode set of commands to do this.
My next attempt was:
:'<,'>g/.*/execute 'normal "Qyi"' | let @q .= "\n"
I used the global
command matching all line of the selection because the execute
command doesn't accept a range. After the yank of text in the normal command I attempt to add a new line character but my q
register ends up like this:
black^Jtall^J^Jtail^J^J
which has a mix of one and two new line characters between the yanked words.
What is the right way to do this? Ideally still using the normal mode commands to yank the text.