I would like to replace parts of one line with the result of the selection being piped into a command.
For example:
echo "hello $(echo "world" | base64)" | vim -
This will open a buffer with hello d29ybGQK in it. Now press wvw to visually select d29ybGQK.
Then I attempted :!base64 -d and I expected the buffer to contain hello world, which did not happen. Indeed, the whole line was piped into the command, and the whole line was replaced.
Is it possible to replace only the visual selection, and have only that selection piped into the command?
I also attempted c<c-r>=system('base64 -d') but that did not send the visual selection to the command's stdin.
:!does not pass the buffer's contents; you either used:.!or:%!for that.:'<,'>!. Try to select one word and press:it will show: '<,'>, and then maybe!xxd -pto change just the selection to hex. All the line will be converted in hex, not just the selection (as per your answer).