I'd like to be able to get the contents of a register in nvi, such as using

b"wye to yank a word into the w register and then invoke a shell command with the current word in it.

Currently, I have this command for running ripgrep (rg), but it's less than ideal in a number of ways.

It basically creates a new line below the current one with an ex command that runs the shell, deletes the new line into the w register and then runs the register via @.

" run ripgrep
map ^R mpb"wyeo^["wpI:!rg --color=always ^[A ^V| less -R^["wdd`p@w

Ideally, is there a way to refer to the contents of a register while typing out an ex command (similar to how <c-r>w would work in vim)?

Alternatively, is there a way to write arbitrary content to a register without touching the file you are currently visiting?

  • Are you constrained to nvi or are vim answer acceptable? Between vim’s scripting language (:let @w = 'foobar') and the <C-r>w that you mention, it would be much easier to do. – D. Ben Knoble Mar 25 at 22:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.