Vim: pipe register for external command

How can I pass the contents of a register to the standard input of an external command? I intuitively tried the following, but it does not work (can serve as an illustration of my need):

:"0w !some_command 
+7
source share
1 answer

If the contents of the register do not contain NULL, then it is as simple as

 call system('some_command', @r) 

. If this happens because using register as a variable converts all of them into new lines (and I don’t know how they are represented inside, besides the fact that registers are not as simple as a structure with a register type and C NULL -end of line), you cannot use this method and should instead insert it into the temporary buffer and use :%w ! . This becomes even more complicated if you want to be able to send the register to some_command completely intact when the register contains both NULL (s) and something other than a new line as the last character.

+11
source

All Articles