I’m trying to execute base64 --decode
on a piece of text selected in Visual mode, but it is the entire line that seems to be passed to the base64
comma
If the text to be passed to the shell command is first yanked to a register, say, the unnamed one, one can use the following command:
:echo system('base64 --decode', @")
It is possible to combine copying the selected text and running the command into a single Visual-mode key mapping:
:vnoremap 64 y:echo system('base64 --decode', @")
The mapping can further be modified to replace the selected text with the output of the shell command via the expression register:
:vnoremap 64 c=system('base64 --decode', @")