I need to pass some selected text in vim to a curl command as a parameter value. For example. I need to be able to run
curl -sSd css="body { border-radius: 5px; }" http://prefixr.com/api/index.php
from vim. Obviously, the "body { border-radius: 5px; }" part will be dynamic. Usually, a visual mode selection in vim.
How do I get the selected text and pass it as a parameter to curl?
You can use the :!
command to filter selected text through an external program.
The text is fed to stdin and substituted with the results from stdout.
In this case you'll have to use cat and command substitution to feed the lines as a parameter to curl, like so:
:'<,'>!curl -sSd css="`cat`" http://prefixr.com/api/index.php