0

I can use the following to yank text inside of quotes across multiple lines, separate that text by a single new line, and be able to paste it characterwise.

let @q = '' | *g/^/exe 'norm! "Qyi"' | call setreg('q', "\n", 'ac')

Applied to the following:

"prop1": "a value",
"propertyTwo": "another value",
"prop3": "yav",
"property four": "final value"

results in the following text in the buffer:

prop1
propertyTwo
prop3
property four

I would like to be able to make this buffer blockwise so I can paste the text across multiple lines. However, if I change my initial command to the following (change 'ac' to 'ab')

let @q = '' | *g/^/exe 'norm! "Qyi"' | call setreg('q', "\n", 'ab')

I end up with extra blank lines. The new blockwise text in the buffer:

prop1
propertyTwo

prop3

property four

How can I copy the text into a blockwise buffer but without the extra new lines?

1
  • :%!column -t -s:
    – balki
    Commented Mar 22 at 13:11

1 Answer 1

0

Since the register is being changed to blockwise appending the newlines in unnecessary and just changing the type is enough:

let @q = '' | *g/^/exe 'norm! "Qyi"' | call setreg('q', @q, 'b')

Removing the a from the 'ab' in setreg() changes it to replace instead of append. Change the value to @q to set the value of the register to its current value.

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.