I'm trying to run a shell command on a visual selection but I can't figure out how to run it on the selection and not the selected lines, eg:
Selection start here
v
hello
world
^ Ends here
Running the following command will send hello\nworld
to my_command
:'<,'>!my_command
How can i send lo\nwor
to my_command
. Where \n
is a newline
Upon reading the :help '<
page I got the impression what '<
should be
simulate to `<:
'< `< To the first line or character of the last selected
Visual area in the current buffer. For block mode it
may also be the last character in the first line (to
be able to define the block). {not in Vi}.
You can achieve something similar using a key map.
vnoremap <C-s> y:! <C-r>0<Home><right>
This will map Ctrl-S
in visual mode. It copies selected text, invokes command line and pastes the selected text and then moves the cursor to enter a command at !
.
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