1

I'd like to assign the result of search range selection into a register, instead of printing it, e.g.:

:/pattern1/;,/pattern2/p

What syntax I can use to achieve that?

2
  • 2
    you mean like using redir/execute()? Dec 20, 2016 at 20:34
  • I'm not sure, could be either way, so I can print the register later on.
    – kenorb
    Dec 20, 2016 at 20:40

1 Answer 1

3

You can use the :yank ex command:

:/pattern1/;/pattern2/yank a

a is the register you want to use and has a default value.

Note: You used ;, in your command. It should be either ; or ,, not both.

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.