How can I pipe the contents of a register to the standard input of an external command? I intuitively tried the following, but it doesn't work (may serve to illustrate my need, though):
:"0w !some_command
If contents of the register does not happen to contain NULLs then it is as simple as
call system('some_command', getreg('r', 1, 1) + (getregtype('r') isnot# 'v' ? [''] : []))
. This form will also preserve NULs which may happen to live inside register, if you know you do not have that you may use @r
in place of getreg()
call. Note though that getreg('r', 1, 1)
will not have trailing newline even if you copied text in linewise mode which is why I have written + (getregtype('r') isnot# 'v' ? [''] : [])
to add it (form @r
does not have this problem).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With